Merge "Use ro.build.type instead of ro.debuggable" into sc-dev
diff --git a/.gitignore b/.gitignore
index 5a5ea87..415166b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,2 @@
*.pyc
*.*~
-libc/kernel/original
diff --git a/docs/fdsan.md b/docs/fdsan.md
index 0e6783d..e0cf80a 100644
--- a/docs/fdsan.md
+++ b/docs/fdsan.md
@@ -2,6 +2,8 @@
[TOC]
+fdsan is a file descriptor sanitizer added to Android in API level 29.
+
### Background
*What problem is fdsan trying to solve? Why should I care?*
diff --git a/docs/fdtrack.md b/docs/fdtrack.md
index 5bc9860..7cf6e1f 100644
--- a/docs/fdtrack.md
+++ b/docs/fdtrack.md
@@ -1,5 +1,9 @@
## fdtrack
+[TOC]
+
+fdtrack is a file descriptor leak checker added to Android in API level 30.
+
fdtrack consists of two parts: a set of hooks in bionic to register a callback
that's invoked on file descriptor operations, and a library that implements a
hook to perform and store backtraces for file descriptor creation.
diff --git a/docs/native_allocator.md b/docs/native_allocator.md
index 139d664..9fc9a31 100644
--- a/docs/native_allocator.md
+++ b/docs/native_allocator.md
@@ -329,7 +329,7 @@
To run these benchmarks, first copy the trace files to the target using
these commands:
- adb shell push system/extras/traces /data/local/tmp
+ adb push system/extras/memory_replay/traces /data/local/tmp
Since all of the traces come from applications, the `memory_replay` program
will always call `mallopt(M_DECAY_TIME, 1)' before running the trace.
diff --git a/libc/Android.bp b/libc/Android.bp
index 4084b96..8922621 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -89,6 +89,7 @@
header_libs: [
"libc_headers",
"gwp_asan_headers",
+ "liblog_headers", // needed by bionic/libc/async_safe/include
],
export_header_lib_headers: [
"libc_headers",
@@ -274,7 +275,7 @@
defaults: ["libc_defaults"],
srcs: [
- "dns/**/*.c",
+ "dns/**/*.c*",
"upstream-netbsd/lib/libc/isc/ev_streams.c",
"upstream-netbsd/lib/libc/isc/ev_timers.c",
@@ -1028,9 +1029,7 @@
"bionic/arpa_inet.cpp",
"bionic/assert.cpp",
"bionic/atof.cpp",
- "bionic/bind.cpp",
"bionic/bionic_allocator.cpp",
- "bionic/bionic_appcompat.cpp",
"bionic/bionic_arc4random.cpp",
"bionic/bionic_futex.cpp",
"bionic/bionic_netlink.cpp",
@@ -1643,7 +1642,6 @@
],
name: "libc",
static_ndk_lib: true,
- llndk_stubs: "libc.llndk",
product_variables: {
platform_sdk_version: {
asflags: ["-DPLATFORM_SDK_VERSION=%d"],
@@ -1767,7 +1765,12 @@
"current",
],
},
-
+ llndk: {
+ symbol_file: "libc.map.txt",
+ export_headers_as_system: true,
+ export_preprocessed_headers: ["include"],
+ export_llndk_headers: ["libc_llndk_headers"],
+ },
apex_available: [
"//apex_available:platform",
"com.android.runtime",
@@ -1858,13 +1861,11 @@
}
cc_library_headers {
- // Internal lib for use in libc_headers. Since we cannot intersect arch{}
- // and target{} in the same module, this one specifies the arch-dependent
- // include paths, and then libc_headers filters by target so that the
- // headers only are included for Bionic targets.
- name: "libc_headers_arch",
+ name: "libc_llndk_headers",
visibility: ["//visibility:private"],
-
+ llndk: {
+ llndk_headers: true,
+ },
host_supported: true,
vendor_available: true,
product_available: true,
@@ -1892,7 +1893,6 @@
sdk_version: "1",
export_system_include_dirs: [
- "include",
"kernel/uapi",
"kernel/android/scsi",
"kernel/android/uapi",
@@ -1955,12 +1955,14 @@
target: {
android: {
- header_libs: ["libc_headers_arch"],
- export_header_lib_headers: ["libc_headers_arch"],
+ export_system_include_dirs: ["include"],
+ header_libs: ["libc_llndk_headers"],
+ export_header_lib_headers: ["libc_llndk_headers"],
},
linux_bionic: {
- header_libs: ["libc_headers_arch"],
- export_header_lib_headers: ["libc_headers_arch"],
+ export_system_include_dirs: ["include"],
+ header_libs: ["libc_llndk_headers"],
+ export_header_lib_headers: ["libc_llndk_headers"],
},
},
bazel_module: { bp2build_available: true },
@@ -2300,41 +2302,6 @@
first_version: "9",
}
-llndk_library {
- name: "libc.llndk",
- symbol_file: "libc.map.txt",
- export_headers_as_system: true,
- export_preprocessed_headers: ["include"],
- native_bridge_supported: true,
- export_include_dirs: [
- "kernel/android/scsi",
- "kernel/android/uapi",
- "kernel/uapi",
- ],
- arch: {
- arm: {
- export_include_dirs: [
- "kernel/uapi/asm-arm",
- ],
- },
- arm64: {
- export_include_dirs: [
- "kernel/uapi/asm-arm64",
- ],
- },
- x86: {
- export_include_dirs: [
- "kernel/uapi/asm-x86",
- ],
- },
- x86_64: {
- export_include_dirs: [
- "kernel/uapi/asm-x86",
- ],
- },
- },
-}
-
ndk_library {
name: "libstdc++",
symbol_file: "libstdc++.map.txt",
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index d263508..391e7af 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -113,7 +113,7 @@
int msync(const void*, size_t, int) all
int mprotect(const void*, size_t, int) all
int madvise(void*, size_t, int) all
-int process_madvise(int, const struct iovec*, size_t, int, unsigned int) all
+ssize_t process_madvise(int, const struct iovec*, size_t, int, unsigned int) all
int mlock(const void* addr, size_t len) all
int mlock2(const void* addr, size_t len, int flags) all
int munlock(const void* addr, size_t len) all
@@ -245,7 +245,7 @@
# sockets
int __socket:socket(int, int, int) arm,lp64
int __socketpair:socketpair(int, int, int, int*) arm,lp64
-int __bind:bind(int, struct sockaddr*, socklen_t) arm,lp64
+int bind(int, struct sockaddr*, socklen_t) arm,lp64
int __connect:connect(int, struct sockaddr*, socklen_t) arm,lp64
int listen(int, int) arm,lp64
int __accept4:accept4(int, struct sockaddr*, socklen_t*, int) arm,lp64
@@ -263,7 +263,7 @@
# sockets for x86. These are done as an "indexed" call to socketcall syscall.
int __socket:socketcall:1(int, int, int) x86
-int __bind:socketcall:2(int, struct sockaddr*, int) x86
+int bind:socketcall:2(int, struct sockaddr*, int) x86
int __connect:socketcall:3(int, struct sockaddr*, socklen_t) x86
int listen:socketcall:4(int, int) x86
int getsockname:socketcall:6(int, struct sockaddr*, socklen_t*) x86
diff --git a/libc/arch-arm/bionic/__bionic_clone.S b/libc/arch-arm/bionic/__bionic_clone.S
index 6669b93..3fe212b 100644
--- a/libc/arch-arm/bionic/__bionic_clone.S
+++ b/libc/arch-arm/bionic/__bionic_clone.S
@@ -61,6 +61,8 @@
b __set_errno_internal
.L_bc_child:
+ # We're in the child now. Set the end of the frame record chain.
+ mov fp, #0
# Setting lr to 0 will make the unwinder stop at __start_thread.
mov lr, #0
# Call __start_thread with the 'fn' and 'arg' we stored on the child stack.
diff --git a/libc/arch-arm/bionic/setjmp.S b/libc/arch-arm/bionic/setjmp.S
index 5fbcaf3..2579143 100644
--- a/libc/arch-arm/bionic/setjmp.S
+++ b/libc/arch-arm/bionic/setjmp.S
@@ -87,28 +87,6 @@
b sigsetjmp
END(_setjmp)
-#define MANGLE_REGISTERS 1
-#define USE_CHECKSUM 1
-
-.macro m_mangle_registers reg
-#if MANGLE_REGISTERS
- eor r4, r4, \reg
- eor r5, r5, \reg
- eor r6, r6, \reg
- eor r7, r7, \reg
- eor r8, r8, \reg
- eor r9, r9, \reg
- eor r10, r10, \reg
- eor r11, r11, \reg
- eor r13, r13, \reg
- eor r14, r14, \reg
-#endif
-.endm
-
-.macro m_unmangle_registers reg
- m_mangle_registers \reg
-.endm
-
.macro m_calculate_checksum dst, src, scratch
mov \dst, #0
.irp i,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28
@@ -167,12 +145,30 @@
// Save core registers.
add r1, r0, #(_JB_CORE_BASE * 4)
- m_mangle_registers r2
-
- // ARM deprecates using sp in the register list for stmia.
- stmia r1, {r4-r11, lr}
- str sp, [r1, #(9 * 4)]
- m_unmangle_registers r2
+ // Mangle the easy registers in-place, write them out in one go, and unmangle
+ // them again.
+ eor r4, r4, r2
+ eor r5, r5, r2
+ eor r6, r6, r2
+ eor r7, r7, r2
+ eor r8, r8, r2
+ eor r9, r9, r2
+ eor r10, r10, r2
+ eor r11, r11, r2
+ stmia r1, {r4-r11}
+ eor r4, r4, r2
+ eor r5, r5, r2
+ eor r6, r6, r2
+ eor r7, r7, r2
+ eor r8, r8, r2
+ eor r9, r9, r2
+ eor r10, r10, r2
+ eor r11, r11, r2
+ // We need to avoid invalid values in sp or lr (http://b/152210274).
+ eor r3, lr, r2
+ str r3, [r1, #(8 * 4)]
+ eor r3, sp, r2
+ str r3, [r1, #(9 * 4)]
// Save floating-point registers.
add r1, r0, #(_JB_FLOAT_BASE * 4)
@@ -182,11 +178,9 @@
fmrx r1, fpscr
str r1, [r0, #(_JB_FLOAT_STATE * 4)]
-#if USE_CHECKSUM
// Calculate the checksum.
m_calculate_checksum r12, r0, r2
str r12, [r0, #(_JB_CHECKSUM * 4)]
-#endif
mov r0, #0
bx lr
@@ -201,14 +195,11 @@
.cfi_rel_offset r1, 4
.cfi_rel_offset lr, 8
-#if USE_CHECKSUM
// Check the checksum before doing anything.
m_calculate_checksum r12, r0, r3
ldr r2, [r0, #(_JB_CHECKSUM * 4)]
-
teq r2, r12
bne __bionic_setjmp_checksum_mismatch
-#endif
// Fetch the signal flag.
ldr r1, [r0, #(_JB_SIGFLAG * 4)]
@@ -245,10 +236,21 @@
// Restore core registers.
add r2, r0, #(_JB_CORE_BASE * 4)
- // ARM deprecates using sp in the register list for ldmia.
- ldmia r2, {r4-r11, lr}
- ldr sp, [r2, #(9 * 4)]
- m_unmangle_registers r3
+ // Do all the easy registers in one go.
+ ldmia r2, {r4-r11}
+ eor r4, r4, r3
+ eor r5, r5, r3
+ eor r6, r6, r3
+ eor r7, r7, r3
+ eor r8, r8, r3
+ eor r9, r9, r3
+ eor r10, r10, r3
+ eor r11, r11, r3
+ // We need to avoid invalid values in sp or lr (http://b/152210274).
+ ldr r0, [r2, #(8 * 4)]
+ eor lr, r0, r3
+ ldr r0, [r2, #(9 * 4)]
+ eor sp, r0, r3
// Save the return value/address and check the setjmp cookie.
stmfd sp!, {r1, lr}
diff --git a/libc/arch-arm64/bionic/setjmp.S b/libc/arch-arm64/bionic/setjmp.S
index 351516f..d2fafdb 100644
--- a/libc/arch-arm64/bionic/setjmp.S
+++ b/libc/arch-arm64/bionic/setjmp.S
@@ -69,11 +69,8 @@
#define _JB_CHECKSUM (_JB_D8_D9 + 2)
#define SCS_MASK (SCS_SIZE - 1)
-#define MANGLE_REGISTERS 1
-#define USE_CHECKSUM 1
.macro m_mangle_registers reg, sp_reg
-#if MANGLE_REGISTERS
eor x3, x3, \reg
eor x19, x19, \reg
eor x20, x20, \reg
@@ -88,7 +85,6 @@
eor x29, x29, \reg
eor x30, x30, \reg
eor \sp_reg, \sp_reg, \reg
-#endif
.endm
.macro m_calculate_checksum dst, src, scratch
@@ -179,11 +175,9 @@
stp d10, d11, [x0, #(_JB_D10_D11 * 8)]
stp d8, d9, [x0, #(_JB_D8_D9 * 8)]
-#if USE_CHECKSUM
// Calculate the checksum.
m_calculate_checksum x12, x0, x2
str x12, [x0, #(_JB_CHECKSUM * 8)]
-#endif
mov w0, #0
autiasp
@@ -194,14 +188,11 @@
// void siglongjmp(sigjmp_buf env, int value);
ENTRY(siglongjmp)
__BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(siglongjmp)
-#if USE_CHECKSUM
// Check the checksum before doing anything.
m_calculate_checksum x12, x0, x2
ldr x2, [x0, #(_JB_CHECKSUM * 8)]
-
cmp x2, x12
bne __bionic_setjmp_checksum_mismatch
-#endif
#if __has_feature(hwaddress_sanitizer)
stp x0, x30, [sp, #-16]!
diff --git a/libc/arch-common/bionic/crtbegin.c b/libc/arch-common/bionic/crtbegin.c
index 62878378..5f681c5 100644
--- a/libc/arch-common/bionic/crtbegin.c
+++ b/libc/arch-common/bionic/crtbegin.c
@@ -49,13 +49,15 @@
#define POST "; .size _start, .-_start"
#if defined(__aarch64__)
-__asm__(PRE "bti j; mov x0,sp; b _start_main" POST);
+__asm__(PRE "bti j; mov x29,#0; mov x30,#0; mov x0,sp; b _start_main" POST);
#elif defined(__arm__)
-__asm__(PRE "mov r0,sp; b _start_main" POST);
+__asm__(PRE "mov fp,#0; mov lr,#0; mov r0,sp; b _start_main" POST);
#elif defined(__i386__)
-__asm__(PRE "movl %esp,%eax; andl $~0xf,%esp; subl $12,%esp; pushl %eax; calll _start_main" POST);
+__asm__(PRE
+ "xorl %ebp,%ebp; movl %esp,%eax; andl $~0xf,%esp; subl $12,%esp; pushl %eax;"
+ "calll _start_main" POST);
#elif defined(__x86_64__)
-__asm__(PRE "movq %rsp,%rdi; andq $~0xf,%rsp; callq _start_main" POST);
+__asm__(PRE "xorl %ebp, %ebp; movq %rsp,%rdi; andq $~0xf,%rsp; callq _start_main" POST);
#else
#error unsupported architecture
#endif
diff --git a/libc/arch-x86/bionic/__bionic_clone.S b/libc/arch-x86/bionic/__bionic_clone.S
index b682b48..f0c58a0 100644
--- a/libc/arch-x86/bionic/__bionic_clone.S
+++ b/libc/arch-x86/bionic/__bionic_clone.S
@@ -45,6 +45,7 @@
.L_bc_child:
# We don't want anyone to unwind past this point.
.cfi_undefined %eip
+ .cfi_undefined %ebp
call __start_thread
hlt
diff --git a/libc/arch-x86/bionic/setjmp.S b/libc/arch-x86/bionic/setjmp.S
index 1e1ce58..1a3eb4b 100644
--- a/libc/arch-x86/bionic/setjmp.S
+++ b/libc/arch-x86/bionic/setjmp.S
@@ -57,19 +57,6 @@
#define _JB_SIGFLAG 8
#define _JB_CHECKSUM 9
-.macro m_mangle_registers reg
- xorl \reg,%edx
- xorl \reg,%ebx
- xorl \reg,%esp
- xorl \reg,%ebp
- xorl \reg,%esi
- xorl \reg,%edi
-.endm
-
-.macro m_unmangle_registers reg
- m_mangle_registers \reg
-.endm
-
.macro m_calculate_checksum dst, src
movl $0, \dst
.irp i,0,1,2,3,4,5
@@ -129,14 +116,17 @@
// Save the callee-save registers.
movl 0(%esp),%edx
- m_mangle_registers %eax
- movl %edx,(_JB_EDX * 4)(%ecx)
- movl %ebx,(_JB_EBX * 4)(%ecx)
- movl %esp,(_JB_ESP * 4)(%ecx)
- movl %ebp,(_JB_EBP * 4)(%ecx)
- movl %esi,(_JB_ESI * 4)(%ecx)
- movl %edi,(_JB_EDI * 4)(%ecx)
- m_unmangle_registers %eax
+
+.macro m_mangle_register reg, offset
+ movl \reg,(\offset * 4)(%ecx)
+ xorl %eax,(\offset * 4)(%ecx)
+.endm
+ m_mangle_register %edx, _JB_EDX
+ m_mangle_register %ebx, _JB_EBX
+ m_mangle_register %esp, _JB_ESP
+ m_mangle_register %ebp, _JB_EBP
+ m_mangle_register %esi, _JB_ESI
+ m_mangle_register %edi, _JB_EDI
m_calculate_checksum %eax, %ecx
movl %eax, (_JB_CHECKSUM * 4)(%ecx)
@@ -174,18 +164,26 @@
movl 4(%esp),%edx
movl 8(%esp),%eax
+ // Fetch the setjmp cookie and clear the signal flag bit.
movl (_JB_SIGFLAG * 4)(%edx),%ecx
andl $-2,%ecx
+ // Carefully unmangle esp/ebp without ever having an invalid value in the
+ // register (http://b/152210274).
+ movl (_JB_ESP * 4)(%edx),%edi
+ xorl %ecx,%edi
+ movl %edi,%esp
+ movl (_JB_EBP * 4)(%edx),%edi
+ xorl %ecx,%edi
+ movl %edi,%ebp
+
+ // The others don't matter as much, but we do need to finish using the cookie
+ // from %ecx before we clobber it, so we seed each register with the cookie.
movl %ecx,%ebx
- movl %ecx,%esp
- movl %ecx,%ebp
movl %ecx,%esi
movl %ecx,%edi
xorl (_JB_EDX * 4)(%edx),%ecx
xorl (_JB_EBX * 4)(%edx),%ebx
- xorl (_JB_ESP * 4)(%edx),%esp
- xorl (_JB_EBP * 4)(%edx),%ebp
xorl (_JB_ESI * 4)(%edx),%esi
xorl (_JB_EDI * 4)(%edx),%edi
diff --git a/libc/arch-x86_64/bionic/setjmp.S b/libc/arch-x86_64/bionic/setjmp.S
index 1d34561..ba3f05f 100644
--- a/libc/arch-x86_64/bionic/setjmp.S
+++ b/libc/arch-x86_64/bionic/setjmp.S
@@ -64,25 +64,6 @@
#define _JB_SIGMASK 9
#define _JB_CHECKSUM 10
-#define MANGLE_REGISTERS 1
-
-.macro m_mangle_registers reg
-#if MANGLE_REGISTERS
- xorq \reg,%rbx
- xorq \reg,%rbp
- xorq \reg,%r12
- xorq \reg,%r13
- xorq \reg,%r14
- xorq \reg,%r15
- xorq \reg,%rsp
- xorq \reg,%r11
-#endif
-.endm
-
-.macro m_unmangle_registers reg
- m_mangle_registers \reg
-.endm
-
.macro m_calculate_checksum dst, src
movq $0, \dst
.irp i,0,1,2,3,4,5,6,7
@@ -127,20 +108,26 @@
popq %rdi // Pop 'env'.
2:
- // Save the callee-save registers.
+ // Fetch the setjmp cookie and clear the signal flag bit.
popq %rax
andq $-2,%rax
movq (%rsp),%r11
- m_mangle_registers %rax
- movq %rbx,(_JB_RBX * 8)(%rdi)
- movq %rbp,(_JB_RBP * 8)(%rdi)
- movq %r12,(_JB_R12 * 8)(%rdi)
- movq %r13,(_JB_R13 * 8)(%rdi)
- movq %r14,(_JB_R14 * 8)(%rdi)
- movq %r15,(_JB_R15 * 8)(%rdi)
- movq %rsp,(_JB_RSP * 8)(%rdi)
- movq %r11,(_JB_PC * 8)(%rdi)
- m_unmangle_registers %rax
+
+ // Save the callee-save registers.
+
+.macro m_mangle_register reg, offset
+ movq \reg, (\offset * 8)(%rdi)
+ xorq %rax, (\offset * 8)(%rdi) // %rax contains the cookie.
+.endm
+
+ m_mangle_register %rbx, _JB_RBX
+ m_mangle_register %rbp, _JB_RBP
+ m_mangle_register %r12, _JB_R12
+ m_mangle_register %r13, _JB_R13
+ m_mangle_register %r14, _JB_R14
+ m_mangle_register %r15, _JB_R15
+ m_mangle_register %rsp, _JB_RSP
+ m_mangle_register %r11, _JB_PC
m_calculate_checksum %rax, %rdi
movq %rax, (_JB_CHECKSUM * 8)(%rdi)
@@ -179,15 +166,22 @@
popq %rax // Pop 'value'.
// Restore the callee-save registers.
- movq (_JB_RBX * 8)(%r12),%rbx
- movq (_JB_RBP * 8)(%r12),%rbp
- movq (_JB_R13 * 8)(%r12),%r13
- movq (_JB_R14 * 8)(%r12),%r14
- movq (_JB_R15 * 8)(%r12),%r15
- movq (_JB_RSP * 8)(%r12),%rsp
- movq (_JB_PC * 8)(%r12),%r11
- movq (_JB_R12 * 8)(%r12),%r12
- m_unmangle_registers %rcx
+
+.macro m_unmangle_register reg, offset
+ movq (\offset * 8)(%r12), %rdx // Clobbers rdx.
+ xorq %rcx, %rdx // %rcx contains the cookie.
+ // Now it's safe to overwrite the register (http://b/152210274).
+ movq %rdx, \reg
+.endm
+
+ m_unmangle_register %rbx, _JB_RBX
+ m_unmangle_register %rbp, _JB_RBP
+ m_unmangle_register %r13, _JB_R13
+ m_unmangle_register %r14, _JB_R14
+ m_unmangle_register %r15, _JB_R15
+ m_unmangle_register %rsp, _JB_RSP
+ m_unmangle_register %r11, _JB_PC
+ m_unmangle_register %r12, _JB_R12
// Check the cookie.
pushq %rax
diff --git a/libc/bionic/bind.cpp b/libc/bionic/bind.cpp
deleted file mode 100644
index 79e8020..0000000
--- a/libc/bionic/bind.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-// b/170214442: Intercept bind calls on NETLINK_ROUTE sockets.
-// This entire file will be reverted before release.
-
-#include <async_safe/log.h>
-#include <errno.h>
-#include <linux/rtnetlink.h>
-#include <string.h>
-#include <sys/socket.h>
-
-#include "bionic_appcompat.h"
-
-extern "C" int __bind(int fd, const struct sockaddr* addr, socklen_t addr_length);
-
-int bind(int fd, const struct sockaddr* addr, socklen_t addr_length) {
- if (should_apply_soft_mac_bind_restrictions()) {
- int sock_domain, sock_protocol;
- socklen_t sock_domain_length = sizeof(sock_domain);
- socklen_t sock_protocol_length = sizeof(sock_protocol);
- if (getsockopt(fd, SOL_SOCKET, SO_DOMAIN, &sock_domain, &sock_domain_length) < 0 ||
- getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &sock_protocol, &sock_protocol_length) < 0) {
- async_safe_format_log(ANDROID_LOG_ERROR, "mac-restrictions",
- "Could not get socket type/protocol: %s", strerror(errno));
- } else if (AF_NETLINK == sock_domain && NETLINK_ROUTE == sock_protocol) {
- char package_name[MAX_PACKAGE_NAME_LENGTH + 1];
- get_package_name(package_name, sizeof(package_name));
- async_safe_format_log(
- ANDROID_LOG_ERROR, "mac-restrictions",
- "%s tried to call bind() on a NETLINK_ROUTE socket, which is not allowed. Please follow "
- "instructions at go/netlink-bug if this app behaves incorrectly.",
- package_name);
- errno = EACCES;
- return -1;
- }
- }
-
- return __bind(fd, addr, addr_length);
-}
diff --git a/libc/bionic/bionic_appcompat.cpp b/libc/bionic/bionic_appcompat.cpp
deleted file mode 100644
index dcca0da..0000000
--- a/libc/bionic/bionic_appcompat.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-// b/170214442: Intercept bind calls on NETLINK_ROUTE sockets and getifaddrs() calls.
-// This entire file will be reverted before release.
-
-#include <async_safe/log.h>
-#include <cutils/misc.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "bionic_appcompat.h"
-
-bool should_apply_soft_mac_restrictions(const char* const allowlist[]) {
- if (getuid() < FIRST_APPLICATION_UID) {
- // System app. No restrictions should be applied.
- return false;
- }
- if (android_get_application_target_sdk_version() >= __ANDROID_API_R__) {
- // Restrictions already applied by SELinux. Behave as normally.
- return false;
- }
-
- char package_name[MAX_PACKAGE_NAME_LENGTH + 1];
- if (get_package_name(package_name, sizeof(package_name)) < 0) {
- // Error in getting own package name. Apply restrictions by default.
- async_safe_format_log(ANDROID_LOG_ERROR, "mac-restrictions",
- "Could not determine own package name for uid %d", getuid());
- return true;
- }
- for (int i = 0; allowlist[i] != nullptr; i++) {
- if (strcmp(package_name, allowlist[i]) == 0) {
- async_safe_format_log(ANDROID_LOG_WARN, "mac-restrictions",
- "Temporarily allowing %s to bypass MAC address restrictions.",
- package_name);
- return false;
- }
- }
- return true;
-}
-
-bool should_apply_soft_mac_bind_restrictions() {
- return should_apply_soft_mac_restrictions(soft_mac_bind_allowlist);
-}
-
-bool should_apply_soft_mac_getlink_restrictions() {
- return should_apply_soft_mac_restrictions(soft_mac_getlink_allowlist);
-}
-
-int get_package_name(char* buffer, const int bufferlen) {
- int file = open("/proc/self/cmdline", O_RDONLY | O_CLOEXEC);
- if (file < 0) {
- return file;
- }
-
- ssize_t len = read(file, buffer, bufferlen - 1);
- if (len < 0) {
- close(file);
- return -1;
- }
- buffer[len] = 0;
-
- close(file);
- return 0;
-}
diff --git a/libc/bionic/fdsan.cpp b/libc/bionic/fdsan.cpp
index 043510c..48e8674 100644
--- a/libc/bionic/fdsan.cpp
+++ b/libc/bionic/fdsan.cpp
@@ -137,14 +137,6 @@
return;
}
- // Lots of code will (sensibly) fork, call close on all of their fds,
- // and then exec. Compare our cached pid value against the real one to detect
- // this scenario and permit it.
- pid_t cached_pid = __get_cached_pid();
- if (cached_pid == 0 || cached_pid != syscall(__NR_getpid)) {
- return;
- }
-
struct {
size_t size;
char buf[512];
diff --git a/libc/bionic/fdtrack.cpp b/libc/bionic/fdtrack.cpp
index 1123512..89a208f 100644
--- a/libc/bionic/fdtrack.cpp
+++ b/libc/bionic/fdtrack.cpp
@@ -37,8 +37,14 @@
_Atomic(android_fdtrack_hook_t) __android_fdtrack_hook;
+bool __android_fdtrack_globally_disabled = false;
+
+void android_fdtrack_set_globally_enabled(bool new_value) {
+ __android_fdtrack_globally_disabled = !new_value;
+}
+
bool android_fdtrack_get_enabled() {
- return !__get_bionic_tls().fdtrack_disabled;
+ return !__get_bionic_tls().fdtrack_disabled && !__android_fdtrack_globally_disabled;
}
bool android_fdtrack_set_enabled(bool new_value) {
diff --git a/libc/bionic/fork.cpp b/libc/bionic/fork.cpp
index 8c5cf2b..d432c6d 100644
--- a/libc/bionic/fork.cpp
+++ b/libc/bionic/fork.cpp
@@ -31,6 +31,7 @@
#include <android/fdsan.h>
#include "private/bionic_defs.h"
+#include "private/bionic_fdtrack.h"
#include "pthread_internal.h"
__BIONIC_WEAK_FOR_NATIVE_BRIDGE_INLINE
@@ -55,9 +56,10 @@
int result = __clone_for_fork();
if (result == 0) {
- // Disable fdsan post-fork, so we don't falsely trigger on processes that
+ // Disable fdsan and fdtrack post-fork, so we don't falsely trigger on processes that
// fork, close all of their fds, and then exec.
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ android_fdtrack_set_globally_enabled(false);
// Reset the stack_and_tls VMA name so it doesn't end with a tid from the
// parent process.
diff --git a/libc/bionic/ifaddrs.cpp b/libc/bionic/ifaddrs.cpp
index 22ecdb4..1536333 100644
--- a/libc/bionic/ifaddrs.cpp
+++ b/libc/bionic/ifaddrs.cpp
@@ -42,7 +42,6 @@
#include "private/ErrnoRestorer.h"
-#include "bionic_appcompat.h"
#include "bionic_netlink.h"
// The public ifaddrs struct is full of pointers. Rather than track several
@@ -311,12 +310,9 @@
// - System apps
// - Apps with a target SDK version lower than R
bool getlink_success = false;
- if (!should_apply_soft_mac_getlink_restrictions()) {
+ if (getuid() < FIRST_APPLICATION_UID ||
+ android_get_application_target_sdk_version() < __ANDROID_API_R__) {
getlink_success = nc.SendRequest(RTM_GETLINK) && nc.ReadResponses(__getifaddrs_callback, out);
- } else if (android_get_application_target_sdk_version() < __ANDROID_API_R__) {
- async_safe_format_log(ANDROID_LOG_WARN, "mac-restrictions",
- "ifaddr no longer returns link info. Please follow instructions at "
- "go/netlink-bug if this app behaves incorrectly.");
}
bool getaddr_success =
nc.SendRequest(RTM_GETADDR) && nc.ReadResponses(__getifaddrs_callback, out);
diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp
index 198bcba..741b45e 100644
--- a/libc/bionic/malloc_heapprofd.cpp
+++ b/libc/bionic/malloc_heapprofd.cpp
@@ -325,12 +325,12 @@
static void CommonInstallHooks(libc_globals* globals) {
void* impl_handle = atomic_load(&gHeapprofdHandle);
- bool reusing_handle = impl_handle != nullptr;
- if (!reusing_handle) {
+ if (impl_handle == nullptr) {
impl_handle = LoadSharedLibrary(kHeapprofdSharedLib, kHeapprofdPrefix, &globals->malloc_dispatch_table);
if (impl_handle == nullptr) {
return;
}
+ atomic_store(&gHeapprofdHandle, impl_handle);
} else if (!InitSharedLibrary(impl_handle, kHeapprofdSharedLib, kHeapprofdPrefix, &globals->malloc_dispatch_table)) {
return;
}
@@ -341,11 +341,7 @@
// MaybeModifyGlobals locks at this point.
atomic_store(&gPreviousDefaultDispatchTable, GetDefaultDispatchTable());
- if (FinishInstallHooks(globals, nullptr, kHeapprofdPrefix)) {
- atomic_store(&gHeapprofdHandle, impl_handle);
- } else if (!reusing_handle) {
- dlclose(impl_handle);
- }
+ FinishInstallHooks(globals, nullptr, kHeapprofdPrefix);
}
void HeapprofdInstallHooksAtInit(libc_globals* globals) {
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 206d5fd..46d9e86 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -30,6 +30,7 @@
#include <errno.h>
#include <string.h>
+#include <sys/auxv.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/random.h>
@@ -344,6 +345,16 @@
__set_stack_and_tls_vma_name(false);
__init_additional_stacks(thread);
__rt_sigprocmask(SIG_SETMASK, &thread->start_mask, nullptr, sizeof(thread->start_mask));
+#ifdef __aarch64__
+ // Chrome's sandbox prevents this prctl, so only reset IA if the target SDK level is high enough.
+ // Furthermore, processes loaded from vendor partitions may have their own sandboxes that would
+ // reject the prctl. Because no devices launched with PAC enabled before S, we can avoid issues on
+ // upgrading devices by checking for PAC support before issuing the prctl.
+ static const bool pac_supported = getauxval(AT_HWCAP) & HWCAP_PACA;
+ if (pac_supported && android_get_application_target_sdk_version() >= __ANDROID_API_S__) {
+ prctl(PR_PAC_RESET_KEYS, PR_PAC_APIAKEY, 0, 0, 0);
+ }
+#endif
void* result = thread->start_routine(thread->start_routine_arg);
pthread_exit(result);
diff --git a/libc/dns/include/resolv_private.h b/libc/dns/include/resolv_private.h
index 77b03bf..3054555 100644
--- a/libc/dns/include/resolv_private.h
+++ b/libc/dns/include/resolv_private.h
@@ -51,8 +51,7 @@
* Id: resolv.h,v 1.7.2.11.4.2 2004/06/25 00:41:05 marka Exp
*/
-#ifndef _RESOLV_PRIVATE_H_
-#define _RESOLV_PRIVATE_H_
+#pragma once
#include <sys/cdefs.h>
@@ -63,6 +62,8 @@
#include <net/if.h>
#include <time.h>
+__BEGIN_DECLS
+
// Linux defines MAXHOSTNAMELEN as 64, while the domain name limit in
// RFC 1034 and RFC 1035 is 255 octets.
#ifdef MAXHOSTNAMELEN
@@ -293,8 +294,6 @@
/* 0x00010000 */
/* Things involving an internal (static) resolver context. */
-__BEGIN_DECLS
-
__LIBC_HIDDEN__ extern struct __res_state *__res_get_state(void);
__LIBC_HIDDEN__ extern void __res_put_state(struct __res_state *);
@@ -307,8 +306,6 @@
#define _res (*__res_state())
#endif
-__END_DECLS
-
#ifndef __BIND_NOSTATIC
#define fp_nquery __fp_nquery
#define fp_query __fp_query
@@ -319,7 +316,6 @@
#define res_isourserver __res_isourserver
#define res_querydomain __res_querydomain
#define res_send __res_send
-#define res_sendsigned __res_sendsigned
#ifdef BIND_RES_POSIX3
#define dn_expand __dn_expand
@@ -329,7 +325,6 @@
#define res_mkquery __res_mkquery
#endif
-__BEGIN_DECLS
void fp_nquery(const u_char *, int, FILE *);
void fp_query(const u_char *, FILE *);
const char * hostalias(const char *);
@@ -343,8 +338,6 @@
int res_querydomain(const char *, const char *, int, int, u_char *, int);
int res_search(const char *, int, int, u_char *, int);
int res_send(const u_char *, int, u_char *, int);
-int res_sendsigned(const u_char *, int, ns_tsig_key *, u_char *, int);
-__END_DECLS
#endif
#if !defined(SHARED_LIBBIND) || defined(LIB)
@@ -424,7 +417,6 @@
#define res_send_setrhook __res_send_setrhook
#define res_servicename __res_servicename
#define res_servicenumber __res_servicenumber
-__BEGIN_DECLS
int res_hnok(const char *);
int res_ownok(const char *);
int res_mailok(const char *);
@@ -532,5 +524,3 @@
int ns_name_labels(ns_nname_ct, size_t);
__END_DECLS
-
-#endif /* !_RESOLV_PRIVATE_H_ */
diff --git a/libc/dns/include/resolv_static.h b/libc/dns/include/resolv_static.h
index 8f2a095..83a435a 100644
--- a/libc/dns/include/resolv_static.h
+++ b/libc/dns/include/resolv_static.h
@@ -1,7 +1,7 @@
-#ifndef _RESOLV_STATIC_H
-#define _RESOLV_STATIC_H
+#pragma once
#include <netdb.h>
+#include <sys/cdefs.h>
/* this structure contains all the variables that were declared
* 'static' in the original NetBSD resolver code.
@@ -15,18 +15,20 @@
#define MAXALIASES 35
#define MAXADDRS 35
-typedef struct res_static {
- char* h_addr_ptrs[MAXADDRS + 1];
- char* host_aliases[MAXALIASES];
- char hostbuf[8*1024];
- u_int32_t host_addr[16 / sizeof(u_int32_t)]; /* IPv4 or IPv6 */
- FILE* hostf;
- int stayopen;
- const char* servent_ptr;
- struct servent servent;
- struct hostent host;
-} *res_static;
+__BEGIN_DECLS
-extern res_static __res_get_static(void);
+struct res_static {
+ char* h_addr_ptrs[MAXADDRS + 1];
+ char* host_aliases[MAXALIASES];
+ char hostbuf[8 * 1024];
+ u_int32_t host_addr[16 / sizeof(u_int32_t)]; /* IPv4 or IPv6 */
+ FILE* hostf;
+ int stayopen;
+ const char* servent_ptr;
+ struct servent servent;
+ struct hostent host;
+};
-#endif /* _RESOLV_STATIC_H */
+struct res_static* __res_get_static(void);
+
+__END_DECLS
diff --git a/libc/dns/net/gethnamaddr.c b/libc/dns/net/gethnamaddr.c
index f8212a2..add124f 100644
--- a/libc/dns/net/gethnamaddr.c
+++ b/libc/dns/net/gethnamaddr.c
@@ -1537,7 +1537,7 @@
gethostbyname(const char *name)
{
struct hostent *result = NULL;
- res_static rs = __res_get_static(); /* Use res_static to provide thread-safety. */
+ struct res_static* rs = __res_get_static();
gethostbyname_r(name, &rs->host, rs->hostbuf, sizeof(rs->hostbuf), &result, &h_errno);
return result;
@@ -1547,7 +1547,7 @@
gethostbyname2(const char *name, int af)
{
struct hostent *result = NULL;
- res_static rs = __res_get_static(); /* Use res_static to provide thread-safety. */
+ struct res_static* rs = __res_get_static();
gethostbyname2_r(name, af, &rs->host, rs->hostbuf, sizeof(rs->hostbuf), &result, &h_errno);
return result;
@@ -1583,7 +1583,7 @@
res_state res = __res_get_state();
if (res == NULL)
return NULL;
- res_static rs = __res_get_static(); /* Use res_static to provide thread-safety. */
+ struct res_static* rs = __res_get_static();
hp = gethostbyname_internal(name, af, res, &rs->host, rs->hostbuf, sizeof(rs->hostbuf),
&h_errno, netcontext);
__res_put_state(res);
@@ -1615,7 +1615,7 @@
android_gethostbyaddrfornetcontext_proxy(const void* addr, socklen_t len, int af,
const struct android_net_context *netcontext)
{
- res_static rs = __res_get_static(); /* Use res_static to provide thread-safety. */
+ struct res_static* rs = __res_get_static();
return android_gethostbyaddrfornetcontext_proxy_internal(addr, len, af, &rs->host, rs->hostbuf,
sizeof(rs->hostbuf), &h_errno, netcontext);
}
@@ -1623,7 +1623,7 @@
struct hostent *
gethostent(void)
{
- res_static rs = __res_get_static();
+ struct res_static* rs = __res_get_static();
if (!rs->hostf) {
sethostent_r(&rs->hostf);
if (!rs->hostf) {
diff --git a/libc/dns/net/getservent.c b/libc/dns/net/getservent.c
index 03add59..6a50d23 100644
--- a/libc/dns/net/getservent.c
+++ b/libc/dns/net/getservent.c
@@ -35,7 +35,7 @@
#include "resolv_static.h"
#include "services.h"
-struct servent* getservent_r(res_static rs) {
+struct servent* getservent_r(struct res_static* rs) {
const char* p;
const char* q;
int namelen;
@@ -109,17 +109,17 @@
}
void endservent(void) {
- res_static rs = __res_get_static();
+ struct res_static* rs = __res_get_static();
if (rs) rs->servent_ptr = NULL;
}
struct servent* getservent(void) {
- res_static rs = __res_get_static();
+ struct res_static* rs = __res_get_static();
return rs ? getservent_r(rs) : NULL;
}
struct servent* getservbyname(const char* name, const char* proto) {
- res_static rs = __res_get_static();
+ struct res_static* rs = __res_get_static();
if (rs == NULL) return NULL;
const char* old_servent_ptr = rs->servent_ptr;
@@ -135,7 +135,7 @@
}
struct servent* getservbyport(int port, const char* proto) {
- res_static rs = __res_get_static();
+ struct res_static* rs = __res_get_static();
if (rs == NULL) return NULL;
const char* old_servent_ptr = rs->servent_ptr;
diff --git a/libc/dns/net/sethostent.c b/libc/dns/net/sethostent.c
index b2b0132..483105a 100644
--- a/libc/dns/net/sethostent.c
+++ b/libc/dns/net/sethostent.c
@@ -65,14 +65,14 @@
/*ARGSUSED*/
sethostent(int stayopen)
{
- res_static rs = __res_get_static();
+ struct res_static* rs = __res_get_static();
if (rs) sethostent_r(&rs->hostf);
}
void
endhostent(void)
{
- res_static rs = __res_get_static();
+ struct res_static* rs = __res_get_static();
if (rs) endhostent_r(&rs->hostf);
}
diff --git a/libc/dns/resolv/res_data.c b/libc/dns/resolv/res_data.c
deleted file mode 100644
index 9bc02e7..0000000
--- a/libc/dns/resolv/res_data.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/* $NetBSD: res_data.c,v 1.8 2004/06/09 18:07:03 christos Exp $ */
-
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1995-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#ifdef notdef
-static const char rcsid[] = "Id: res_data.c,v 1.1.206.2 2004/03/16 12:34:18 marka Exp";
-#else
-__RCSID("$NetBSD: res_data.c,v 1.8 2004/06/09 18:07:03 christos Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
-#include <ctype.h>
-#include <netdb.h>
-#include "resolv_private.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-
-__LIBC_HIDDEN__
-const char * const _res_opcodes[] = {
- "QUERY",
- "IQUERY",
- "CQUERYM",
- "CQUERYU", /* experimental */
- "NOTIFY", /* experimental */
- "UPDATE",
- "6",
- "7",
- "8",
- "9",
- "10",
- "11",
- "12",
- "13",
- "ZONEINIT",
- "ZONEREF",
-};
-
-#ifdef BIND_UPDATE
-const char * const _res_sectioncodes[] = {
- "ZONE",
- "PREREQUISITES",
- "UPDATE",
- "ADDITIONAL",
-};
-#endif
-
-#ifndef __BIND_NOSTATIC
-extern struct __res_state _nres;
-
-/* Proto. */
-
-int res_ourserver_p(const res_state, const struct sockaddr *);
-
-#define res_need_init() ((_nres.options & RES_INIT) == 0U)
-
-int
-res_init(void) {
- int rv;
- extern int __res_vinit(res_state, int);
-#ifdef COMPAT__RES
- /*
- * Compatibility with program that were accessing _res directly
- * to set options. We keep another struct res that is the same
- * size as the original res structure, and then copy fields to
- * it so that we achieve the same initialization
- */
- extern void *__res_get_old_state(void);
- extern void __res_put_old_state(void *);
- res_state ores = __res_get_old_state();
-
- if (ores->options != 0)
- _nres.options = ores->options;
- if (ores->retrans != 0)
- _nres.retrans = ores->retrans;
- if (ores->retry != 0)
- _nres.retry = ores->retry;
-#endif
-
- /*
- * These three fields used to be statically initialized. This made
- * it hard to use this code in a shared library. It is necessary,
- * now that we're doing dynamic initialization here, that we preserve
- * the old semantics: if an application modifies one of these three
- * fields of _res before res_init() is called, res_init() will not
- * alter them. Of course, if an application is setting them to
- * _zero_ before calling res_init(), hoping to override what used
- * to be the static default, we can't detect it and unexpected results
- * will follow. Zero for any of these fields would make no sense,
- * so one can safely assume that the applications were already getting
- * unexpected results.
- *
- * _nres.options is tricky since some apps were known to diddle the bits
- * before res_init() was first called. We can't replicate that semantic
- * with dynamic initialization (they may have turned bits off that are
- * set in RES_DEFAULT). Our solution is to declare such applications
- * "broken". They could fool us by setting RES_INIT but none do (yet).
- */
- if (!_nres.retrans)
- _nres.retrans = RES_TIMEOUT;
- if (!_nres.retry)
- _nres.retry = 4;
- if (!(_nres.options & RES_INIT))
- _nres.options = RES_DEFAULT;
-
- /*
- * This one used to initialize implicitly to zero, so unless the app
- * has set it to something in particular, we can randomize it now.
- */
- if (!_nres.id)
- _nres.id = res_randomid();
-
- rv = __res_vinit(&_nres, 1);
-#ifdef COMPAT__RES
- __res_put_old_state(&_nres);
-#endif
- return rv;
-}
-
-void
-p_query(const u_char *msg) {
- fp_query(msg, stdout);
-}
-
-void
-fp_query(const u_char *msg, FILE *file) {
- fp_nquery(msg, PACKETSZ, file);
-}
-
-void
-fp_nquery(const u_char *msg, int len, FILE *file) {
- if (res_need_init() && res_init() == -1)
- return;
-
- res_pquery(&_nres, msg, len, file);
-}
-
-int
-res_mkquery(int op, /* opcode of query */
- const char *dname, /* domain name */
- int class, int type, /* class and type of query */
- const u_char *data, /* resource record data */
- int datalen, /* length of data */
- const u_char *newrr_in, /* new rr for modify or append */
- u_char *buf, /* buffer to put query */
- int buflen) /* size of buffer */
-{
- if (res_need_init() && res_init() == -1) {
- RES_SET_H_ERRNO(&_nres, NETDB_INTERNAL);
- return (-1);
- }
- return (res_nmkquery(&_nres, op, dname, class, type,
- data, datalen,
- newrr_in, buf, buflen));
-}
-
-#ifdef _LIBRESOLV
-int
-res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
- if (res_need_init() && res_init() == -1) {
- RES_SET_H_ERRNO(&_nres, NETDB_INTERNAL);
- return (-1);
- }
-
- return (res_nmkupdate(&_nres, rrecp_in, buf, buflen));
-}
-#endif
-
-int
-res_query(const char *name, /* domain name */
- int class, int type, /* class and type of query */
- u_char *answer, /* buffer to put answer */
- int anslen) /* size of answer buffer */
-{
- if (res_need_init() && res_init() == -1) {
- RES_SET_H_ERRNO(&_nres, NETDB_INTERNAL);
- return (-1);
- }
- return (res_nquery(&_nres, name, class, type, answer, anslen));
-}
-
-void
-res_send_setqhook(res_send_qhook hook) {
- _nres.qhook = hook;
-}
-
-void
-res_send_setrhook(res_send_rhook hook) {
- _nres.rhook = hook;
-}
-
-int
-res_isourserver(const struct sockaddr_in *inp) {
- return (res_ourserver_p(&_nres, (const struct sockaddr *)(const void *)inp));
-}
-
-int
-res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) {
- if (res_need_init() && res_init() == -1) {
- /* errno should have been set by res_init() in this case. */
- return (-1);
- }
-
- return (res_nsend(&_nres, buf, buflen, ans, anssiz));
-}
-
-#ifdef _LIBRESOLV
-int
-res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key,
- u_char *ans, int anssiz)
-{
- if (res_need_init() && res_init() == -1) {
- /* errno should have been set by res_init() in this case. */
- return (-1);
- }
-
- return (res_nsendsigned(&_nres, buf, buflen, key, ans, anssiz));
-}
-#endif
-
-void
-res_close(void) {
- res_nclose(&_nres);
-}
-
-#ifdef _LIBRESOLV
-int
-res_update(ns_updrec *rrecp_in) {
- if (res_need_init() && res_init() == -1) {
- RES_SET_H_ERRNO(&_nres, NETDB_INTERNAL);
- return (-1);
- }
-
- return (res_nupdate(&_nres, rrecp_in, NULL));
-}
-#endif
-
-int
-res_search(const char *name, /* domain name */
- int class, int type, /* class and type of query */
- u_char *answer, /* buffer to put answer */
- int anslen) /* size of answer */
-{
- if (res_need_init() && res_init() == -1) {
- RES_SET_H_ERRNO(&_nres, NETDB_INTERNAL);
- return (-1);
- }
-
- return (res_nsearch(&_nres, name, class, type, answer, anslen));
-}
-
-int
-res_querydomain(const char *name,
- const char *domain,
- int class, int type, /* class and type of query */
- u_char *answer, /* buffer to put answer */
- int anslen) /* size of answer */
-{
- if (res_need_init() && res_init() == -1) {
- RES_SET_H_ERRNO(&_nres, NETDB_INTERNAL);
- return (-1);
- }
-
- return (res_nquerydomain(&_nres, name, domain,
- class, type,
- answer, anslen));
-}
-
-int
-res_opt(int a, u_char *b, int c, int d)
-{
- return res_nopt(&_nres, a, b, c, d);
-}
-
-const char *
-hostalias(const char *name) {
- return NULL;
-}
-
-#ifdef ultrix
-int
-local_hostname_length(const char *hostname) {
- int len_host, len_domain;
-
- if (!*_nres.defdname)
- res_init();
- len_host = strlen(hostname);
- len_domain = strlen(_nres.defdname);
- if (len_host > len_domain &&
- !strcasecmp(hostname + len_host - len_domain, _nres.defdname) &&
- hostname[len_host - len_domain - 1] == '.')
- return (len_host - len_domain - 1);
- return (0);
-}
-#endif /*ultrix*/
-
-#endif
diff --git a/libc/dns/resolv/res_data.cpp b/libc/dns/resolv/res_data.cpp
new file mode 100644
index 0000000..22d9f7b
--- /dev/null
+++ b/libc/dns/resolv/res_data.cpp
@@ -0,0 +1,157 @@
+/* $NetBSD: res_data.c,v 1.8 2004/06/09 18:07:03 christos Exp $ */
+
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "resolv_private.h"
+
+#include <pthread.h>
+
+extern "C" int res_ourserver_p(const res_state, const struct sockaddr*);
+extern "C" int __res_vinit(res_state, int);
+
+class GlobalStateAccessor {
+ public:
+ GlobalStateAccessor() {
+ pthread_mutex_lock(&mutex);
+ if (!initialized) {
+ init();
+ initialized = true;
+ }
+ }
+
+ ~GlobalStateAccessor() {
+ pthread_mutex_unlock(&mutex);
+ }
+
+ __res_state* get() {
+ return &state;
+ }
+
+ int init();
+
+ private:
+ static __res_state state;
+ static bool initialized;
+ static pthread_mutex_t mutex;
+};
+__res_state GlobalStateAccessor::state;
+bool GlobalStateAccessor::initialized = false;
+pthread_mutex_t GlobalStateAccessor::mutex = PTHREAD_MUTEX_INITIALIZER;
+
+int GlobalStateAccessor::init() {
+ // These three fields used to be statically initialized. This made
+ // it hard to use this code in a shared library. It is necessary,
+ // now that we're doing dynamic initialization here, that we preserve
+ // the old semantics: if an application modifies one of these three
+ // fields of _res before res_init() is called, res_init() will not
+ // alter them. Of course, if an application is setting them to
+ // _zero_ before calling res_init(), hoping to override what used
+ // to be the static default, we can't detect it and unexpected results
+ // will follow. Zero for any of these fields would make no sense,
+ // so one can safely assume that the applications were already getting
+ // unexpected results.
+ // g_nres.options is tricky since some apps were known to diddle the bits
+ // before res_init() was first called. We can't replicate that semantic
+ // with dynamic initialization (they may have turned bits off that are
+ // set in RES_DEFAULT). Our solution is to declare such applications
+ // "broken". They could fool us by setting RES_INIT but none do (yet).
+ if (!state.retrans) state.retrans = RES_TIMEOUT;
+ if (!state.retry) state.retry = 4;
+ if (!(state.options & RES_INIT)) state.options = RES_DEFAULT;
+
+ // This one used to initialize implicitly to zero, so unless the app
+ // has set it to something in particular, we can randomize it now.
+ if (!state.id) state.id = res_randomid();
+
+ return __res_vinit(&state, 1);
+}
+
+int res_init(void) {
+ GlobalStateAccessor gsa;
+ return gsa.init();
+}
+
+void p_query(const u_char* msg) {
+ fp_query(msg, stdout);
+}
+
+void fp_query(const u_char* msg, FILE* file) {
+ fp_nquery(msg, PACKETSZ, file);
+}
+
+void fp_nquery(const u_char* msg, int len, FILE* file) {
+ GlobalStateAccessor gsa;
+ res_pquery(gsa.get(), msg, len, file);
+}
+
+int
+res_mkquery(int op, const char* dname, int klass, int type, const u_char* data,
+ int datalen, const u_char* newrr_in, u_char* buf, int buflen) {
+ GlobalStateAccessor gsa;
+ return res_nmkquery(gsa.get(), op, dname, klass, type, data, datalen, newrr_in, buf, buflen);
+}
+
+int res_query(const char* name, int klass, int type, u_char* answer, int anslen) {
+ GlobalStateAccessor gsa;
+ return res_nquery(gsa.get(), name, klass, type, answer, anslen);
+}
+
+void res_send_setqhook(res_send_qhook hook) {
+ GlobalStateAccessor gsa;
+ gsa.get()->qhook = hook;
+}
+
+void res_send_setrhook(res_send_rhook hook) {
+ GlobalStateAccessor gsa;
+ gsa.get()->rhook = hook;
+}
+
+int res_isourserver(const struct sockaddr_in* inp) {
+ GlobalStateAccessor gsa;
+ return res_ourserver_p(gsa.get(), reinterpret_cast<const sockaddr*>(inp));
+}
+
+int res_send(const u_char* buf, int buflen, u_char* ans, int anssiz) {
+ GlobalStateAccessor gsa;
+ return res_nsend(gsa.get(), buf, buflen, ans, anssiz);
+}
+
+void res_close(void) {
+ GlobalStateAccessor gsa;
+ res_nclose(gsa.get());
+}
+
+int res_search(const char* name, int klass, int type, u_char* answer, int anslen) {
+ GlobalStateAccessor gsa;
+ return res_nsearch(gsa.get(), name, klass, type, answer, anslen);
+}
+
+int res_querydomain(const char* name, const char* domain, int klass, int type, u_char* answer,
+ int anslen) {
+ GlobalStateAccessor gsa;
+ return res_nquerydomain(gsa.get(), name, domain, klass, type, answer, anslen);
+}
+
+int res_opt(int a, u_char* b, int c, int d) {
+ GlobalStateAccessor gsa;
+ return res_nopt(gsa.get(), a, b, c, d);
+}
+
+const char* hostalias(const char* name) {
+ return NULL;
+}
diff --git a/libc/dns/resolv/res_debug.c b/libc/dns/resolv/res_debug.c
index 5f889cb..4fe7553 100644
--- a/libc/dns/resolv/res_debug.c
+++ b/libc/dns/resolv/res_debug.c
@@ -126,9 +126,27 @@
#include <strings.h>
#include <time.h>
-extern const char * const _res_opcodes[];
extern const char * const _res_sectioncodes[];
+__LIBC_HIDDEN__ const char* const _res_opcodes[] = {
+ "QUERY",
+ "IQUERY",
+ "CQUERYM",
+ "CQUERYU", /* experimental */
+ "NOTIFY", /* experimental */
+ "UPDATE",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "ZONEINIT",
+ "ZONEREF",
+};
+
#ifndef _LIBC
/*
* Print the current options.
diff --git a/libc/dns/resolv/res_state.c b/libc/dns/resolv/res_state.c
index 94124ff..d1f5c24 100644
--- a/libc/dns/resolv/res_state.c
+++ b/libc/dns/resolv/res_state.c
@@ -68,7 +68,7 @@
}
static void
-_res_static_done( res_static rs )
+_res_static_done(struct res_static* rs)
{
/* fortunately, there is nothing to do here, since the
* points in h_addr_ptrs and host_aliases should all
@@ -135,25 +135,6 @@
return rt;
}
-__LIBC_HIDDEN__
-struct __res_state _nres;
-
-#if 0
-struct resolv_cache*
-__get_res_cache(void)
-{
- _res_thread* rt = _res_thread_get();
-
- if (!rt)
- return NULL;
-
- if (!rt->_cache) {
- rt->_cache = _resolv_cache_create();
- }
- return rt->_cache;
-}
-#endif
-
int*
__get_h_errno(void)
{
@@ -177,9 +158,7 @@
/* nothing to do */
}
-res_static
-__res_get_static(void)
-{
+struct res_static* __res_get_static(void) {
_res_thread* rt = _res_thread_get();
return rt ? rt->_rstatic : NULL;
diff --git a/libc/include/bits/glibc-syscalls.h b/libc/include/bits/glibc-syscalls.h
index 6b00f11..fbda7fe 100644
--- a/libc/include/bits/glibc-syscalls.h
+++ b/libc/include/bits/glibc-syscalls.h
@@ -606,6 +606,9 @@
#if defined(__NR_mount)
#define SYS_mount __NR_mount
#endif
+#if defined(__NR_mount_setattr)
+ #define SYS_mount_setattr __NR_mount_setattr
+#endif
#if defined(__NR_move_mount)
#define SYS_move_mount __NR_move_mount
#endif
diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h
index 3b44dab..6ef0c12 100644
--- a/libc/include/sys/mman.h
+++ b/libc/include/sys/mman.h
@@ -167,9 +167,9 @@
* works just like madvise(2) but applies to the process specified by the given
* PID file descriptor.
*
- * Returns 0 on success, and returns -1 and sets `errno` on failure.
+ * Returns the number of bytes advised on success, and returns -1 and sets `errno` on failure.
*/
-int process_madvise(int __pid_fd, const struct iovec* __iov, size_t __count, int __advice, unsigned int __flags);
+ssize_t process_madvise(int __pid_fd, const struct iovec* __iov, size_t __count, int __advice, unsigned __flags);
#if defined(__USE_GNU)
diff --git a/libc/kernel/android/scsi/scsi/scsi.h b/libc/kernel/android/scsi/scsi/scsi.h
index 1e125d1..2ea16a3 100644
--- a/libc/kernel/android/scsi/scsi/scsi.h
+++ b/libc/kernel/android/scsi/scsi/scsi.h
@@ -57,6 +57,7 @@
#define CLEAR_TASK_SET 0x0e
#define INITIATE_RECOVERY 0x0f
#define RELEASE_RECOVERY 0x10
+#define TERMINATE_IO_PROC 0x11
#define CLEAR_ACA 0x16
#define LOGICAL_UNIT_RESET 0x17
#define SIMPLE_QUEUE_TAG 0x20
diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py
index 2c2d001..cfd301a 100755
--- a/libc/kernel/tools/clean_header.py
+++ b/libc/kernel/tools/clean_header.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#------------------------------------------------------------------------------
# Description of the header clean process
@@ -127,7 +127,7 @@
if __name__ == "__main__":
def usage():
- print """\
+ print("""\
usage: %s [options] <header_path>
options:
@@ -142,7 +142,7 @@
-d<path> specify path of cleaned kernel headers
<header_path> must be in a subdirectory of 'original'
- """ % os.path.basename(sys.argv[0])
+ """ % os.path.basename(sys.argv[0]))
sys.exit(1)
try:
@@ -211,9 +211,8 @@
else:
r = "added"
- print "cleaning: %-*s -> %-*s (%s)" % (35, path, 35, path, r)
+ print("cleaning: %-*s -> %-*s (%s)" % (35, path, 35, path, r))
-
- b.updateGitFiles()
+ b.updateFiles()
sys.exit(0)
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 8538eb0..5488641 100755
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""A glorified C pre-processor parser."""
import ctypes
@@ -14,7 +14,7 @@
utils.panic('ANDROID_BUILD_TOP not set.\n')
# Set up the env vars for libclang.
-site.addsitedir(os.path.join(top, 'external/clang/bindings/python'))
+site.addsitedir(os.path.join(top, 'prebuilts/clang/host/linux-x86/clang-stable/lib64/python3/site-packages/'))
import clang.cindex
from clang.cindex import conf
@@ -28,7 +28,7 @@
# Set up LD_LIBRARY_PATH to include libclang.so, libLLVM.so, and etc.
# Note that setting LD_LIBRARY_PATH with os.putenv() sometimes doesn't help.
-clang.cindex.Config.set_library_file(os.path.join(top, 'prebuilts/sdk/tools/linux/lib64/libclang_android.so'))
+clang.cindex.Config.set_library_file(os.path.join(top, 'prebuilts/clang/host/linux-x86/clang-stable/lib64/libclang.so'))
from defaults import *
@@ -254,7 +254,7 @@
token_group = TokenGroup(self._tu, tokens_memory, tokens_count)
tokens = []
- for i in xrange(0, count):
+ for i in range(0, count):
token = Token(self._tu, token_group,
int_data=tokens_array[i].int_data,
ptr_data=tokens_array[i].ptr_data,
@@ -394,10 +394,10 @@
self._index = 0
if debugCppExpr:
- print "CppExpr: trying to parse %s" % repr(tokens)
+ print("CppExpr: trying to parse %s" % repr(tokens))
self.expr = self.parseExpression(0)
if debugCppExpr:
- print "CppExpr: got " + repr(self.expr)
+ print("CppExpr: got " + repr(self.expr))
if self._index != self._num_tokens:
self.throw(BadExpectedToken, "crap at end of input (%d != %d): %s"
% (self._index, self._num_tokens, repr(tokens)))
@@ -405,9 +405,9 @@
def throw(self, exception, msg):
if self._index < self._num_tokens:
tok = self.tokens[self._index]
- print "%d:%d: %s" % (tok.location.line, tok.location.column, msg)
+ print("%d:%d: %s" % (tok.location.line, tok.location.column, msg))
else:
- print "EOF: %s" % msg
+ print("EOF: %s" % msg)
raise exception(msg)
def expectId(self, id):
@@ -722,7 +722,7 @@
if op == "defined":
op, name = e
- if macros.has_key(name):
+ if name in macros:
if macros[name] == kCppUndefinedMacro:
return ("int", 0)
else:
@@ -739,7 +739,7 @@
elif op == "ident":
op, name = e
- if macros.has_key(name):
+ if name in macros:
try:
value = int(macros[name])
expanded = ("int", value)
@@ -1179,11 +1179,11 @@
def dump(self):
"""Dump all the blocks in current BlockList."""
- print '##### BEGIN #####'
+ print('##### BEGIN #####')
for i, b in enumerate(self.blocks):
- print '### BLOCK %d ###' % i
- print b
- print '##### END #####'
+ print('### BLOCK %d ###' % i)
+ print(b)
+ print('##### END #####')
def optimizeIf01(self):
"""Remove the code between #if 0 .. #endif in a BlockList."""
@@ -1510,7 +1510,7 @@
while i < len(tokens) and tokens[i].location in extent:
t = tokens[i]
if debugBlockParser:
- print ' ' * 2, t.id, t.kind, t.cursor.kind
+ print(' ' * 2, t.id, t.kind, t.cursor.kind)
if (detect_change and t.cursor.extent != extent and
t.cursor.kind == CursorKind.PREPROCESSING_DIRECTIVE):
break
diff --git a/libc/kernel/tools/kernel.py b/libc/kernel/tools/kernel.py
index b6418a8..69d516b 100644
--- a/libc/kernel/tools/kernel.py
+++ b/libc/kernel/tools/kernel.py
@@ -4,7 +4,7 @@
# list here the macros that you know are always defined/undefined when including
# the kernel headers
#
-import sys, cpp, re, os.path, string, time
+import sys, cpp, re, os.path, time
from defaults import *
verboseSearch = 0
@@ -56,7 +56,7 @@
# <mtd/*>
#
re_combined_str=\
- r"^.*<((%s)/[\d\w_\+\.\-/]*)>.*$" % string.join(kernel_dirs,"|")
+ r"^.*<((%s)/[\d\w_\+\.\-/]*)>.*$" % "|".join(kernel_dirs)
re_combined = re.compile(re_combined_str)
@@ -100,7 +100,7 @@
if from_file:
if verboseFind:
- print "=== %s uses %s" % (from_file, header)
+ print("=== %s uses %s" % (from_file, header))
self.headers[header].add(from_file)
def parseFile(self, path, arch=None, kernel_root=None):
@@ -114,7 +114,7 @@
try:
f = open(path, "rt")
except:
- print "!!! can't read '%s'" % path
+ print("!!! can't read '%s'" % path)
return
hasIncludes = False
@@ -125,10 +125,10 @@
break
if not hasIncludes:
- if verboseSearch: print "::: " + path
+ if verboseSearch: print("::: " + path)
return
- if verboseSearch: print "*** " + path
+ if verboseSearch: print("*** " + path)
list = cpp.BlockParser().parseFile(path)
if list:
@@ -205,7 +205,6 @@
if len(kernel_root) > 0 and kernel_root[-1] != "/":
kernel_root += "/"
- #print "using kernel_root %s" % kernel_root
self.archs = archs
self.searched = set(headers)
self.kernel_root = kernel_root
@@ -300,8 +299,8 @@
self.items = {}
self.duplicates = False
- def parseLine(self,line):
- line = string.strip(line)
+ def parseLine(self, line):
+ line = line.strip()
# skip empty and comment lines
if len(line) == 0 or line[0] == "#":
diff --git a/libc/kernel/tools/update_all.py b/libc/kernel/tools/update_all.py
index cef24dd..6206248 100755
--- a/libc/kernel/tools/update_all.py
+++ b/libc/kernel/tools/update_all.py
@@ -1,11 +1,11 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
-import sys, cpp, kernel, glob, os, re, getopt, clean_header, subprocess, shutil
+import sys, cpp, kernel, glob, os, re, getopt, clean_header, shutil
from defaults import *
from utils import *
def Usage():
- print """\
+ print("""\
usage: %(progname)s [kernel-original-path] [kernel-modified-path]
this program is used to update all the auto-generated clean headers
@@ -21,14 +21,14 @@
- the clean headers will be placed in 'bionic/libc/kernel/arch-<arch>/asm',
'bionic/libc/kernel/android', etc..
-""" % { "progname" : os.path.basename(sys.argv[0]) }
+""" % { "progname" : os.path.basename(sys.argv[0]) })
sys.exit(0)
def ProcessFiles(updater, original_dir, modified_dir, src_rel_dir, update_rel_dir):
# Delete the old headers before updating to the new headers.
update_dir = os.path.join(get_kernel_dir(), update_rel_dir)
shutil.rmtree(update_dir)
- os.mkdir(update_dir, 0755)
+ os.mkdir(update_dir, 0o755)
src_dir = os.path.normpath(os.path.join(original_dir, src_rel_dir))
src_dir_len = len(src_dir) + 1
@@ -62,7 +62,7 @@
else:
state = "added"
update_path = os.path.join(update_rel_dir, rel_path)
- print "cleaning %s -> %s (%s)" % (src_str, update_path, state)
+ print("cleaning %s -> %s (%s)" % (src_str, update_path, state))
# This lets us support regular system calls like __NR_write and also weird
@@ -149,9 +149,10 @@
# Now process the special files.
ProcessFiles(updater, original_dir, modified_dir, "scsi", os.path.join("android", "scsi", "scsi"))
-updater.updateGitFiles()
+# Copy all of the files.
+updater.updateFiles()
# Now re-generate the <bits/glibc-syscalls.h> from the new uapi headers.
updater = BatchFileUpdater()
GenerateGlibcSyscallsHeader(updater)
-updater.updateGitFiles()
+updater.updateFiles()
diff --git a/libc/kernel/tools/utils.py b/libc/kernel/tools/utils.py
index 1b06b1b..3b4828b 100644
--- a/libc/kernel/tools/utils.py
+++ b/libc/kernel/tools/utils.py
@@ -1,6 +1,5 @@
# common python utility routines for the Bionic tool scripts
-import commands
import logging
import os
import string
@@ -146,19 +145,3 @@
for dst in sorted(deletes):
os.remove(dst)
-
- def updateGitFiles(self):
- adds, deletes, edits = self.getChanges()
-
- if adds:
- for dst in sorted(adds):
- self._writeFile(dst)
- commands.getoutput("git add " + " ".join(adds))
-
- if deletes:
- commands.getoutput("git rm " + " ".join(deletes))
-
- if edits:
- for dst in sorted(edits):
- self._writeFile(dst)
- commands.getoutput("git add " + " ".join(edits))
diff --git a/libc/kernel/uapi/asm-arm/asm/unistd-common.h b/libc/kernel/uapi/asm-arm/asm/unistd-common.h
index 6068bd2..070c77b 100644
--- a/libc/kernel/uapi/asm-arm/asm/unistd-common.h
+++ b/libc/kernel/uapi/asm-arm/asm/unistd-common.h
@@ -413,4 +413,5 @@
#define __NR_faccessat2 (__NR_SYSCALL_BASE + 439)
#define __NR_process_madvise (__NR_SYSCALL_BASE + 440)
#define __NR_epoll_pwait2 (__NR_SYSCALL_BASE + 441)
+#define __NR_mount_setattr (__NR_SYSCALL_BASE + 442)
#endif
diff --git a/libc/kernel/uapi/asm-generic/unistd.h b/libc/kernel/uapi/asm-generic/unistd.h
index f284254..1409701 100644
--- a/libc/kernel/uapi/asm-generic/unistd.h
+++ b/libc/kernel/uapi/asm-generic/unistd.h
@@ -402,8 +402,9 @@
#define __NR_faccessat2 439
#define __NR_process_madvise 440
#define __NR_epoll_pwait2 441
+#define __NR_mount_setattr 442
#undef __NR_syscalls
-#define __NR_syscalls 442
+#define __NR_syscalls 443
#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
#define __NR_fcntl __NR3264_fcntl
#define __NR_statfs __NR3264_statfs
diff --git a/libc/kernel/uapi/asm-x86/asm/kvm.h b/libc/kernel/uapi/asm-x86/asm/kvm.h
index 7740002..0d82c5d 100644
--- a/libc/kernel/uapi/asm-x86/asm/kvm.h
+++ b/libc/kernel/uapi/asm-x86/asm/kvm.h
@@ -111,6 +111,7 @@
#define KVM_IRQCHIP_IOAPIC 2
#define KVM_NR_IRQCHIPS 3
#define KVM_RUN_X86_SMM (1 << 0)
+#define KVM_RUN_X86_BUS_LOCK (1 << 1)
struct kvm_regs {
__u64 rax, rbx, rcx, rdx;
__u64 rsi, rdi, rsp, rbp;
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_32.h b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
index ca34f04..7fe2421 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
@@ -449,4 +449,5 @@
#define __NR_faccessat2 439
#define __NR_process_madvise 440
#define __NR_epoll_pwait2 441
+#define __NR_mount_setattr 442
#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_64.h b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
index 82268bd..7e3c924 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_64.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
@@ -371,4 +371,5 @@
#define __NR_faccessat2 439
#define __NR_process_madvise 440
#define __NR_epoll_pwait2 441
+#define __NR_mount_setattr 442
#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
index b5b39ad..529ded3 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
@@ -324,6 +324,7 @@
#define __NR_faccessat2 (__X32_SYSCALL_BIT + 439)
#define __NR_process_madvise (__X32_SYSCALL_BIT + 440)
#define __NR_epoll_pwait2 (__X32_SYSCALL_BIT + 441)
+#define __NR_mount_setattr (__X32_SYSCALL_BIT + 442)
#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
diff --git a/libc/kernel/uapi/asm-x86/asm/vmx.h b/libc/kernel/uapi/asm-x86/asm/vmx.h
index fc10e02..1771faa 100644
--- a/libc/kernel/uapi/asm-x86/asm/vmx.h
+++ b/libc/kernel/uapi/asm-x86/asm/vmx.h
@@ -79,7 +79,8 @@
#define EXIT_REASON_XRSTORS 64
#define EXIT_REASON_UMWAIT 67
#define EXIT_REASON_TPAUSE 68
-#define VMX_EXIT_REASONS { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, { EXIT_REASON_INIT_SIGNAL, "INIT_SIGNAL" }, { EXIT_REASON_SIPI_SIGNAL, "SIPI_SIGNAL" }, { EXIT_REASON_INTERRUPT_WINDOW, "INTERRUPT_WINDOW" }, { EXIT_REASON_NMI_WINDOW, "NMI_WINDOW" }, { EXIT_REASON_TASK_SWITCH, "TASK_SWITCH" }, { EXIT_REASON_CPUID, "CPUID" }, { EXIT_REASON_HLT, "HLT" }, { EXIT_REASON_INVD, "INVD" }, { EXIT_REASON_INVLPG, "INVLPG" }, { EXIT_REASON_RDPMC, "RDPMC" }, { EXIT_REASON_RDTSC, "RDTSC" }, { EXIT_REASON_VMCALL, "VMCALL" }, { EXIT_REASON_VMCLEAR, "VMCLEAR" }, { EXIT_REASON_VMLAUNCH, "VMLAUNCH" }, { EXIT_REASON_VMPTRLD, "VMPTRLD" }, { EXIT_REASON_VMPTRST, "VMPTRST" }, { EXIT_REASON_VMREAD, "VMREAD" }, { EXIT_REASON_VMRESUME, "VMRESUME" }, { EXIT_REASON_VMWRITE, "VMWRITE" }, { EXIT_REASON_VMOFF, "VMOFF" }, { EXIT_REASON_VMON, "VMON" }, { EXIT_REASON_CR_ACCESS, "CR_ACCESS" }, { EXIT_REASON_DR_ACCESS, "DR_ACCESS" }, { EXIT_REASON_IO_INSTRUCTION, "IO_INSTRUCTION" }, { EXIT_REASON_MSR_READ, "MSR_READ" }, { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, { EXIT_REASON_INVALID_STATE, "INVALID_STATE" }, { EXIT_REASON_MSR_LOAD_FAIL, "MSR_LOAD_FAIL" }, { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, { EXIT_REASON_MONITOR_TRAP_FLAG, "MONITOR_TRAP_FLAG" }, { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, { EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, { EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, { EXIT_REASON_EOI_INDUCED, "EOI_INDUCED" }, { EXIT_REASON_GDTR_IDTR, "GDTR_IDTR" }, { EXIT_REASON_LDTR_TR, "LDTR_TR" }, { EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, { EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, { EXIT_REASON_INVEPT, "INVEPT" }, { EXIT_REASON_RDTSCP, "RDTSCP" }, { EXIT_REASON_PREEMPTION_TIMER, "PREEMPTION_TIMER" }, { EXIT_REASON_INVVPID, "INVVPID" }, { EXIT_REASON_WBINVD, "WBINVD" }, { EXIT_REASON_XSETBV, "XSETBV" }, { EXIT_REASON_APIC_WRITE, "APIC_WRITE" }, { EXIT_REASON_RDRAND, "RDRAND" }, { EXIT_REASON_INVPCID, "INVPCID" }, { EXIT_REASON_VMFUNC, "VMFUNC" }, { EXIT_REASON_ENCLS, "ENCLS" }, { EXIT_REASON_RDSEED, "RDSEED" }, { EXIT_REASON_PML_FULL, "PML_FULL" }, { EXIT_REASON_XSAVES, "XSAVES" }, { EXIT_REASON_XRSTORS, "XRSTORS" }, { EXIT_REASON_UMWAIT, "UMWAIT" }, { EXIT_REASON_TPAUSE, "TPAUSE" }
+#define EXIT_REASON_BUS_LOCK 74
+#define VMX_EXIT_REASONS { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, { EXIT_REASON_EXTERNAL_INTERRUPT, "EXTERNAL_INTERRUPT" }, { EXIT_REASON_TRIPLE_FAULT, "TRIPLE_FAULT" }, { EXIT_REASON_INIT_SIGNAL, "INIT_SIGNAL" }, { EXIT_REASON_SIPI_SIGNAL, "SIPI_SIGNAL" }, { EXIT_REASON_INTERRUPT_WINDOW, "INTERRUPT_WINDOW" }, { EXIT_REASON_NMI_WINDOW, "NMI_WINDOW" }, { EXIT_REASON_TASK_SWITCH, "TASK_SWITCH" }, { EXIT_REASON_CPUID, "CPUID" }, { EXIT_REASON_HLT, "HLT" }, { EXIT_REASON_INVD, "INVD" }, { EXIT_REASON_INVLPG, "INVLPG" }, { EXIT_REASON_RDPMC, "RDPMC" }, { EXIT_REASON_RDTSC, "RDTSC" }, { EXIT_REASON_VMCALL, "VMCALL" }, { EXIT_REASON_VMCLEAR, "VMCLEAR" }, { EXIT_REASON_VMLAUNCH, "VMLAUNCH" }, { EXIT_REASON_VMPTRLD, "VMPTRLD" }, { EXIT_REASON_VMPTRST, "VMPTRST" }, { EXIT_REASON_VMREAD, "VMREAD" }, { EXIT_REASON_VMRESUME, "VMRESUME" }, { EXIT_REASON_VMWRITE, "VMWRITE" }, { EXIT_REASON_VMOFF, "VMOFF" }, { EXIT_REASON_VMON, "VMON" }, { EXIT_REASON_CR_ACCESS, "CR_ACCESS" }, { EXIT_REASON_DR_ACCESS, "DR_ACCESS" }, { EXIT_REASON_IO_INSTRUCTION, "IO_INSTRUCTION" }, { EXIT_REASON_MSR_READ, "MSR_READ" }, { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, { EXIT_REASON_INVALID_STATE, "INVALID_STATE" }, { EXIT_REASON_MSR_LOAD_FAIL, "MSR_LOAD_FAIL" }, { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, { EXIT_REASON_MONITOR_TRAP_FLAG, "MONITOR_TRAP_FLAG" }, { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, { EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, { EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, { EXIT_REASON_EOI_INDUCED, "EOI_INDUCED" }, { EXIT_REASON_GDTR_IDTR, "GDTR_IDTR" }, { EXIT_REASON_LDTR_TR, "LDTR_TR" }, { EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, { EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, { EXIT_REASON_INVEPT, "INVEPT" }, { EXIT_REASON_RDTSCP, "RDTSCP" }, { EXIT_REASON_PREEMPTION_TIMER, "PREEMPTION_TIMER" }, { EXIT_REASON_INVVPID, "INVVPID" }, { EXIT_REASON_WBINVD, "WBINVD" }, { EXIT_REASON_XSETBV, "XSETBV" }, { EXIT_REASON_APIC_WRITE, "APIC_WRITE" }, { EXIT_REASON_RDRAND, "RDRAND" }, { EXIT_REASON_INVPCID, "INVPCID" }, { EXIT_REASON_VMFUNC, "VMFUNC" }, { EXIT_REASON_ENCLS, "ENCLS" }, { EXIT_REASON_RDSEED, "RDSEED" }, { EXIT_REASON_PML_FULL, "PML_FULL" }, { EXIT_REASON_XSAVES, "XSAVES" }, { EXIT_REASON_XRSTORS, "XRSTORS" }, { EXIT_REASON_UMWAIT, "UMWAIT" }, { EXIT_REASON_TPAUSE, "TPAUSE" }, { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }
#define VMX_EXIT_REASON_FLAGS { VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" }
#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
diff --git a/libc/kernel/uapi/drm/drm_fourcc.h b/libc/kernel/uapi/drm/drm_fourcc.h
index de01ddf..4574c1c 100644
--- a/libc/kernel/uapi/drm/drm_fourcc.h
+++ b/libc/kernel/uapi/drm/drm_fourcc.h
@@ -153,6 +153,7 @@
#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5)
#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS fourcc_mod_code(INTEL, 6)
#define I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS fourcc_mod_code(INTEL, 7)
+#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8)
#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1)
#define DRM_FORMAT_MOD_SAMSUNG_16_16_TILE fourcc_mod_code(SAMSUNG, 2)
#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1)
@@ -204,9 +205,9 @@
#define AFBC_FORMAT_MOD_USM (1ULL << 12)
#define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL)
#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)
-#define __fourcc_mod_amlogic_layout_mask 0xf
+#define __fourcc_mod_amlogic_layout_mask 0xff
#define __fourcc_mod_amlogic_options_shift 8
-#define __fourcc_mod_amlogic_options_mask 0xf
+#define __fourcc_mod_amlogic_options_mask 0xff
#define DRM_FORMAT_MOD_AMLOGIC_FBC(__layout,__options) fourcc_mod_code(AMLOGIC, ((__layout) & __fourcc_mod_amlogic_layout_mask) | (((__options) & __fourcc_mod_amlogic_options_mask) << __fourcc_mod_amlogic_options_shift))
#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL)
#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL)
diff --git a/libc/kernel/uapi/drm/i915_drm.h b/libc/kernel/uapi/drm/i915_drm.h
index c634925..f265d92 100644
--- a/libc/kernel/uapi/drm/i915_drm.h
+++ b/libc/kernel/uapi/drm/i915_drm.h
@@ -67,6 +67,7 @@
#define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1)
#define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2)
#define I915_PMU_RC6_RESIDENCY __I915_PMU_OTHER(3)
+#define I915_PMU_SOFTWARE_GT_AWAKE_TIME __I915_PMU_OTHER(4)
#define I915_PMU_LAST I915_PMU_RC6_RESIDENCY
#define I915_NR_TEX_REGIONS 255
#define I915_LOG_MIN_TEX_REGION_SIZE 14
diff --git a/libc/kernel/uapi/linux/acrn.h b/libc/kernel/uapi/linux/acrn.h
new file mode 100644
index 0000000..74b719a
--- /dev/null
+++ b/libc/kernel/uapi/linux/acrn.h
@@ -0,0 +1,263 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_ACRN_H
+#define _UAPI_ACRN_H
+#include <linux/types.h>
+#include <linux/uuid.h>
+#define ACRN_IO_REQUEST_MAX 16
+#define ACRN_IOREQ_STATE_PENDING 0
+#define ACRN_IOREQ_STATE_COMPLETE 1
+#define ACRN_IOREQ_STATE_PROCESSING 2
+#define ACRN_IOREQ_STATE_FREE 3
+#define ACRN_IOREQ_TYPE_PORTIO 0
+#define ACRN_IOREQ_TYPE_MMIO 1
+#define ACRN_IOREQ_TYPE_PCICFG 2
+#define ACRN_IOREQ_DIR_READ 0
+#define ACRN_IOREQ_DIR_WRITE 1
+struct acrn_mmio_request {
+ __u32 direction;
+ __u32 reserved;
+ __u64 address;
+ __u64 size;
+ __u64 value;
+};
+struct acrn_pio_request {
+ __u32 direction;
+ __u32 reserved;
+ __u64 address;
+ __u64 size;
+ __u32 value;
+};
+struct acrn_pci_request {
+ __u32 direction;
+ __u32 reserved[3];
+ __u64 size;
+ __u32 value;
+ __u32 bus;
+ __u32 dev;
+ __u32 func;
+ __u32 reg;
+};
+struct acrn_io_request {
+ __u32 type;
+ __u32 completion_polling;
+ __u32 reserved0[14];
+ union {
+ struct acrn_pio_request pio_request;
+ struct acrn_pci_request pci_request;
+ struct acrn_mmio_request mmio_request;
+ __u64 data[8];
+ } reqs;
+ __u32 reserved1;
+ __u32 kernel_handled;
+ __u32 processed;
+} __attribute__((aligned(256)));
+struct acrn_io_request_buffer {
+ union {
+ struct acrn_io_request req_slot[ACRN_IO_REQUEST_MAX];
+ __u8 reserved[4096];
+ };
+};
+struct acrn_ioreq_notify {
+ __u16 vmid;
+ __u16 reserved;
+ __u32 vcpu;
+};
+struct acrn_vm_creation {
+ __u16 vmid;
+ __u16 reserved0;
+ __u16 vcpu_num;
+ __u16 reserved1;
+ guid_t uuid;
+ __u64 vm_flag;
+ __u64 ioreq_buf;
+ __u64 cpu_affinity;
+};
+struct acrn_gp_regs {
+ __le64 rax;
+ __le64 rcx;
+ __le64 rdx;
+ __le64 rbx;
+ __le64 rsp;
+ __le64 rbp;
+ __le64 rsi;
+ __le64 rdi;
+ __le64 r8;
+ __le64 r9;
+ __le64 r10;
+ __le64 r11;
+ __le64 r12;
+ __le64 r13;
+ __le64 r14;
+ __le64 r15;
+};
+struct acrn_descriptor_ptr {
+ __le16 limit;
+ __le64 base;
+ __le16 reserved[3];
+} __attribute__((__packed__));
+struct acrn_regs {
+ struct acrn_gp_regs gprs;
+ struct acrn_descriptor_ptr gdt;
+ struct acrn_descriptor_ptr idt;
+ __le64 rip;
+ __le64 cs_base;
+ __le64 cr0;
+ __le64 cr4;
+ __le64 cr3;
+ __le64 ia32_efer;
+ __le64 rflags;
+ __le64 reserved_64[4];
+ __le32 cs_ar;
+ __le32 cs_limit;
+ __le32 reserved_32[3];
+ __le16 cs_sel;
+ __le16 ss_sel;
+ __le16 ds_sel;
+ __le16 es_sel;
+ __le16 fs_sel;
+ __le16 gs_sel;
+ __le16 ldt_sel;
+ __le16 tr_sel;
+};
+struct acrn_vcpu_regs {
+ __u16 vcpu_id;
+ __u16 reserved[3];
+ struct acrn_regs vcpu_regs;
+};
+#define ACRN_MEM_ACCESS_RIGHT_MASK 0x00000007U
+#define ACRN_MEM_ACCESS_READ 0x00000001U
+#define ACRN_MEM_ACCESS_WRITE 0x00000002U
+#define ACRN_MEM_ACCESS_EXEC 0x00000004U
+#define ACRN_MEM_ACCESS_RWX (ACRN_MEM_ACCESS_READ | ACRN_MEM_ACCESS_WRITE | ACRN_MEM_ACCESS_EXEC)
+#define ACRN_MEM_TYPE_MASK 0x000007C0U
+#define ACRN_MEM_TYPE_WB 0x00000040U
+#define ACRN_MEM_TYPE_WT 0x00000080U
+#define ACRN_MEM_TYPE_UC 0x00000100U
+#define ACRN_MEM_TYPE_WC 0x00000200U
+#define ACRN_MEM_TYPE_WP 0x00000400U
+#define ACRN_MEMMAP_RAM 0
+#define ACRN_MEMMAP_MMIO 1
+struct acrn_vm_memmap {
+ __u32 type;
+ __u32 attr;
+ __u64 user_vm_pa;
+ union {
+ __u64 service_vm_pa;
+ __u64 vma_base;
+ };
+ __u64 len;
+};
+#define ACRN_PTDEV_IRQ_INTX 0
+#define ACRN_PTDEV_IRQ_MSI 1
+#define ACRN_PTDEV_IRQ_MSIX 2
+struct acrn_ptdev_irq {
+ __u32 type;
+ __u16 virt_bdf;
+ __u16 phys_bdf;
+ struct {
+ __u32 virt_pin;
+ __u32 phys_pin;
+ __u32 is_pic_pin;
+ } intx;
+};
+#define ACRN_PTDEV_QUIRK_ASSIGN (1U << 0)
+#define ACRN_PCI_NUM_BARS 6
+struct acrn_pcidev {
+ __u32 type;
+ __u16 virt_bdf;
+ __u16 phys_bdf;
+ __u8 intr_line;
+ __u8 intr_pin;
+ __u32 bar[ACRN_PCI_NUM_BARS];
+};
+struct acrn_msi_entry {
+ __u64 msi_addr;
+ __u64 msi_data;
+};
+struct acrn_acpi_generic_address {
+ __u8 space_id;
+ __u8 bit_width;
+ __u8 bit_offset;
+ __u8 access_size;
+ __u64 address;
+} __attribute__((__packed__));
+struct acrn_cstate_data {
+ struct acrn_acpi_generic_address cx_reg;
+ __u8 type;
+ __u32 latency;
+ __u64 power;
+};
+struct acrn_pstate_data {
+ __u64 core_frequency;
+ __u64 power;
+ __u64 transition_latency;
+ __u64 bus_master_latency;
+ __u64 control;
+ __u64 status;
+};
+#define PMCMD_TYPE_MASK 0x000000ff
+enum acrn_pm_cmd_type {
+ ACRN_PMCMD_GET_PX_CNT,
+ ACRN_PMCMD_GET_PX_DATA,
+ ACRN_PMCMD_GET_CX_CNT,
+ ACRN_PMCMD_GET_CX_DATA,
+};
+#define ACRN_IOEVENTFD_FLAG_PIO 0x01
+#define ACRN_IOEVENTFD_FLAG_DATAMATCH 0x02
+#define ACRN_IOEVENTFD_FLAG_DEASSIGN 0x04
+struct acrn_ioeventfd {
+ __u32 fd;
+ __u32 flags;
+ __u64 addr;
+ __u32 len;
+ __u32 reserved;
+ __u64 data;
+};
+#define ACRN_IRQFD_FLAG_DEASSIGN 0x01
+struct acrn_irqfd {
+ __s32 fd;
+ __u32 flags;
+ struct acrn_msi_entry msi;
+};
+#define ACRN_IOCTL_TYPE 0xA2
+#define ACRN_IOCTL_CREATE_VM _IOWR(ACRN_IOCTL_TYPE, 0x10, struct acrn_vm_creation)
+#define ACRN_IOCTL_DESTROY_VM _IO(ACRN_IOCTL_TYPE, 0x11)
+#define ACRN_IOCTL_START_VM _IO(ACRN_IOCTL_TYPE, 0x12)
+#define ACRN_IOCTL_PAUSE_VM _IO(ACRN_IOCTL_TYPE, 0x13)
+#define ACRN_IOCTL_RESET_VM _IO(ACRN_IOCTL_TYPE, 0x15)
+#define ACRN_IOCTL_SET_VCPU_REGS _IOW(ACRN_IOCTL_TYPE, 0x16, struct acrn_vcpu_regs)
+#define ACRN_IOCTL_INJECT_MSI _IOW(ACRN_IOCTL_TYPE, 0x23, struct acrn_msi_entry)
+#define ACRN_IOCTL_VM_INTR_MONITOR _IOW(ACRN_IOCTL_TYPE, 0x24, unsigned long)
+#define ACRN_IOCTL_SET_IRQLINE _IOW(ACRN_IOCTL_TYPE, 0x25, __u64)
+#define ACRN_IOCTL_NOTIFY_REQUEST_FINISH _IOW(ACRN_IOCTL_TYPE, 0x31, struct acrn_ioreq_notify)
+#define ACRN_IOCTL_CREATE_IOREQ_CLIENT _IO(ACRN_IOCTL_TYPE, 0x32)
+#define ACRN_IOCTL_ATTACH_IOREQ_CLIENT _IO(ACRN_IOCTL_TYPE, 0x33)
+#define ACRN_IOCTL_DESTROY_IOREQ_CLIENT _IO(ACRN_IOCTL_TYPE, 0x34)
+#define ACRN_IOCTL_CLEAR_VM_IOREQ _IO(ACRN_IOCTL_TYPE, 0x35)
+#define ACRN_IOCTL_SET_MEMSEG _IOW(ACRN_IOCTL_TYPE, 0x41, struct acrn_vm_memmap)
+#define ACRN_IOCTL_UNSET_MEMSEG _IOW(ACRN_IOCTL_TYPE, 0x42, struct acrn_vm_memmap)
+#define ACRN_IOCTL_SET_PTDEV_INTR _IOW(ACRN_IOCTL_TYPE, 0x53, struct acrn_ptdev_irq)
+#define ACRN_IOCTL_RESET_PTDEV_INTR _IOW(ACRN_IOCTL_TYPE, 0x54, struct acrn_ptdev_irq)
+#define ACRN_IOCTL_ASSIGN_PCIDEV _IOW(ACRN_IOCTL_TYPE, 0x55, struct acrn_pcidev)
+#define ACRN_IOCTL_DEASSIGN_PCIDEV _IOW(ACRN_IOCTL_TYPE, 0x56, struct acrn_pcidev)
+#define ACRN_IOCTL_PM_GET_CPU_STATE _IOWR(ACRN_IOCTL_TYPE, 0x60, __u64)
+#define ACRN_IOCTL_IOEVENTFD _IOW(ACRN_IOCTL_TYPE, 0x70, struct acrn_ioeventfd)
+#define ACRN_IOCTL_IRQFD _IOW(ACRN_IOCTL_TYPE, 0x71, struct acrn_irqfd)
+#endif
diff --git a/libc/kernel/uapi/linux/binfmts.h b/libc/kernel/uapi/linux/binfmts.h
index 8c4fed0..053be3c 100644
--- a/libc/kernel/uapi/linux/binfmts.h
+++ b/libc/kernel/uapi/linux/binfmts.h
@@ -23,4 +23,6 @@
#define MAX_ARG_STRLEN (PAGE_SIZE * 32)
#define MAX_ARG_STRINGS 0x7FFFFFFF
#define BINPRM_BUF_SIZE 256
+#define AT_FLAGS_PRESERVE_ARGV0_BIT 0
+#define AT_FLAGS_PRESERVE_ARGV0 (1 << AT_FLAGS_PRESERVE_ARGV0_BIT)
#endif
diff --git a/libc/kernel/uapi/linux/bpf.h b/libc/kernel/uapi/linux/bpf.h
index 9ee7fbd..c643ffa 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_ATOMIC 0xc0
#define BPF_XADD 0xc0
#define BPF_MOV 0xb0
#define BPF_ARSH 0xc0
@@ -40,6 +41,9 @@
#define BPF_JSLE 0xd0
#define BPF_CALL 0x80
#define BPF_EXIT 0x90
+#define BPF_FETCH 0x01
+#define BPF_XCHG (0xe0 | BPF_FETCH)
+#define BPF_CMPXCHG (0xf0 | BPF_FETCH)
enum {
BPF_REG_0 = 0,
BPF_REG_1,
@@ -456,7 +460,7 @@
__u32 flags;
} prog_bind_map;
} __attribute__((aligned(8)));
-#define __BPF_FUNC_MAPPER(FN) FN(unspec), FN(map_lookup_elem), FN(map_update_elem), FN(map_delete_elem), FN(probe_read), FN(ktime_get_ns), FN(trace_printk), FN(get_prandom_u32), FN(get_smp_processor_id), FN(skb_store_bytes), FN(l3_csum_replace), FN(l4_csum_replace), FN(tail_call), FN(clone_redirect), FN(get_current_pid_tgid), FN(get_current_uid_gid), FN(get_current_comm), FN(get_cgroup_classid), FN(skb_vlan_push), FN(skb_vlan_pop), FN(skb_get_tunnel_key), FN(skb_set_tunnel_key), FN(perf_event_read), FN(redirect), FN(get_route_realm), FN(perf_event_output), FN(skb_load_bytes), FN(get_stackid), FN(csum_diff), FN(skb_get_tunnel_opt), FN(skb_set_tunnel_opt), FN(skb_change_proto), FN(skb_change_type), FN(skb_under_cgroup), FN(get_hash_recalc), FN(get_current_task), FN(probe_write_user), FN(current_task_under_cgroup), FN(skb_change_tail), FN(skb_pull_data), FN(csum_update), FN(set_hash_invalid), FN(get_numa_node_id), FN(skb_change_head), FN(xdp_adjust_head), FN(probe_read_str), FN(get_socket_cookie), FN(get_socket_uid), FN(set_hash), FN(setsockopt), FN(skb_adjust_room), FN(redirect_map), FN(sk_redirect_map), FN(sock_map_update), FN(xdp_adjust_meta), FN(perf_event_read_value), FN(perf_prog_read_value), FN(getsockopt), FN(override_return), FN(sock_ops_cb_flags_set), FN(msg_redirect_map), FN(msg_apply_bytes), FN(msg_cork_bytes), FN(msg_pull_data), FN(bind), FN(xdp_adjust_tail), FN(skb_get_xfrm_state), FN(get_stack), FN(skb_load_bytes_relative), FN(fib_lookup), FN(sock_hash_update), FN(msg_redirect_hash), FN(sk_redirect_hash), FN(lwt_push_encap), FN(lwt_seg6_store_bytes), FN(lwt_seg6_adjust_srh), FN(lwt_seg6_action), FN(rc_repeat), FN(rc_keydown), FN(skb_cgroup_id), FN(get_current_cgroup_id), FN(get_local_storage), FN(sk_select_reuseport), FN(skb_ancestor_cgroup_id), FN(sk_lookup_tcp), FN(sk_lookup_udp), FN(sk_release), FN(map_push_elem), FN(map_pop_elem), FN(map_peek_elem), FN(msg_push_data), FN(msg_pop_data), FN(rc_pointer_rel), FN(spin_lock), FN(spin_unlock), FN(sk_fullsock), FN(tcp_sock), FN(skb_ecn_set_ce), FN(get_listener_sock), FN(skc_lookup_tcp), FN(tcp_check_syncookie), FN(sysctl_get_name), FN(sysctl_get_current_value), FN(sysctl_get_new_value), FN(sysctl_set_new_value), FN(strtol), FN(strtoul), FN(sk_storage_get), FN(sk_storage_delete), FN(send_signal), FN(tcp_gen_syncookie), FN(skb_output), FN(probe_read_user), FN(probe_read_kernel), FN(probe_read_user_str), FN(probe_read_kernel_str), FN(tcp_send_ack), FN(send_signal_thread), FN(jiffies64), FN(read_branch_records), FN(get_ns_current_pid_tgid), FN(xdp_output), FN(get_netns_cookie), FN(get_current_ancestor_cgroup_id), FN(sk_assign), FN(ktime_get_boot_ns), FN(seq_printf), FN(seq_write), FN(sk_cgroup_id), FN(sk_ancestor_cgroup_id), FN(ringbuf_output), FN(ringbuf_reserve), FN(ringbuf_submit), FN(ringbuf_discard), FN(ringbuf_query), FN(csum_level), FN(skc_to_tcp6_sock), FN(skc_to_tcp_sock), FN(skc_to_tcp_timewait_sock), FN(skc_to_tcp_request_sock), FN(skc_to_udp6_sock), FN(get_task_stack), FN(load_hdr_opt), FN(store_hdr_opt), FN(reserve_hdr_opt), FN(inode_storage_get), FN(inode_storage_delete), FN(d_path), FN(copy_from_user), FN(snprintf_btf), FN(seq_printf_btf), FN(skb_cgroup_classid), FN(redirect_neigh), FN(per_cpu_ptr), FN(this_cpu_ptr), FN(redirect_peer), FN(task_storage_get), FN(task_storage_delete), FN(get_current_task_btf), FN(bprm_opts_set), FN(ktime_get_coarse_ns), FN(ima_inode_hash), FN(sock_from_file),
+#define __BPF_FUNC_MAPPER(FN) FN(unspec), FN(map_lookup_elem), FN(map_update_elem), FN(map_delete_elem), FN(probe_read), FN(ktime_get_ns), FN(trace_printk), FN(get_prandom_u32), FN(get_smp_processor_id), FN(skb_store_bytes), FN(l3_csum_replace), FN(l4_csum_replace), FN(tail_call), FN(clone_redirect), FN(get_current_pid_tgid), FN(get_current_uid_gid), FN(get_current_comm), FN(get_cgroup_classid), FN(skb_vlan_push), FN(skb_vlan_pop), FN(skb_get_tunnel_key), FN(skb_set_tunnel_key), FN(perf_event_read), FN(redirect), FN(get_route_realm), FN(perf_event_output), FN(skb_load_bytes), FN(get_stackid), FN(csum_diff), FN(skb_get_tunnel_opt), FN(skb_set_tunnel_opt), FN(skb_change_proto), FN(skb_change_type), FN(skb_under_cgroup), FN(get_hash_recalc), FN(get_current_task), FN(probe_write_user), FN(current_task_under_cgroup), FN(skb_change_tail), FN(skb_pull_data), FN(csum_update), FN(set_hash_invalid), FN(get_numa_node_id), FN(skb_change_head), FN(xdp_adjust_head), FN(probe_read_str), FN(get_socket_cookie), FN(get_socket_uid), FN(set_hash), FN(setsockopt), FN(skb_adjust_room), FN(redirect_map), FN(sk_redirect_map), FN(sock_map_update), FN(xdp_adjust_meta), FN(perf_event_read_value), FN(perf_prog_read_value), FN(getsockopt), FN(override_return), FN(sock_ops_cb_flags_set), FN(msg_redirect_map), FN(msg_apply_bytes), FN(msg_cork_bytes), FN(msg_pull_data), FN(bind), FN(xdp_adjust_tail), FN(skb_get_xfrm_state), FN(get_stack), FN(skb_load_bytes_relative), FN(fib_lookup), FN(sock_hash_update), FN(msg_redirect_hash), FN(sk_redirect_hash), FN(lwt_push_encap), FN(lwt_seg6_store_bytes), FN(lwt_seg6_adjust_srh), FN(lwt_seg6_action), FN(rc_repeat), FN(rc_keydown), FN(skb_cgroup_id), FN(get_current_cgroup_id), FN(get_local_storage), FN(sk_select_reuseport), FN(skb_ancestor_cgroup_id), FN(sk_lookup_tcp), FN(sk_lookup_udp), FN(sk_release), FN(map_push_elem), FN(map_pop_elem), FN(map_peek_elem), FN(msg_push_data), FN(msg_pop_data), FN(rc_pointer_rel), FN(spin_lock), FN(spin_unlock), FN(sk_fullsock), FN(tcp_sock), FN(skb_ecn_set_ce), FN(get_listener_sock), FN(skc_lookup_tcp), FN(tcp_check_syncookie), FN(sysctl_get_name), FN(sysctl_get_current_value), FN(sysctl_get_new_value), FN(sysctl_set_new_value), FN(strtol), FN(strtoul), FN(sk_storage_get), FN(sk_storage_delete), FN(send_signal), FN(tcp_gen_syncookie), FN(skb_output), FN(probe_read_user), FN(probe_read_kernel), FN(probe_read_user_str), FN(probe_read_kernel_str), FN(tcp_send_ack), FN(send_signal_thread), FN(jiffies64), FN(read_branch_records), FN(get_ns_current_pid_tgid), FN(xdp_output), FN(get_netns_cookie), FN(get_current_ancestor_cgroup_id), FN(sk_assign), FN(ktime_get_boot_ns), FN(seq_printf), FN(seq_write), FN(sk_cgroup_id), FN(sk_ancestor_cgroup_id), FN(ringbuf_output), FN(ringbuf_reserve), FN(ringbuf_submit), FN(ringbuf_discard), FN(ringbuf_query), FN(csum_level), FN(skc_to_tcp6_sock), FN(skc_to_tcp_sock), FN(skc_to_tcp_timewait_sock), FN(skc_to_tcp_request_sock), FN(skc_to_udp6_sock), FN(get_task_stack), FN(load_hdr_opt), FN(store_hdr_opt), FN(reserve_hdr_opt), FN(inode_storage_get), FN(inode_storage_delete), FN(d_path), FN(copy_from_user), FN(snprintf_btf), FN(seq_printf_btf), FN(skb_cgroup_classid), FN(redirect_neigh), FN(per_cpu_ptr), FN(this_cpu_ptr), FN(redirect_peer), FN(task_storage_get), FN(task_storage_delete), FN(get_current_task_btf), FN(bprm_opts_set), FN(ktime_get_coarse_ns), FN(ima_inode_hash), FN(sock_from_file), FN(check_mtu),
#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
enum bpf_func_id {
__BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
@@ -783,6 +787,7 @@
__aligned_u64 prog_tags;
__u64 run_time_ns;
__u64 run_cnt;
+ __u64 recursion_misses;
} __attribute__((aligned(8)));
struct bpf_map_info {
__u32 type;
@@ -1001,7 +1006,10 @@
__u8 l4_protocol;
__be16 sport;
__be16 dport;
- __u16 tot_len;
+ union {
+ __u16 tot_len;
+ __u16 mtu_result;
+ };
__u32 ifindex;
union {
__u8 tos;
@@ -1028,6 +1036,14 @@
__u32 ipv6_nh[4];
};
};
+enum bpf_check_mtu_flags {
+ BPF_MTU_CHK_SEGS = (1U << 0),
+};
+enum bpf_check_mtu_ret {
+ BPF_MTU_CHK_RET_SUCCESS,
+ BPF_MTU_CHK_RET_FRAG_NEEDED,
+ BPF_MTU_CHK_RET_SEGS_TOOBIG,
+};
enum bpf_task_fd_type {
BPF_FD_TYPE_RAW_TRACEPOINT,
BPF_FD_TYPE_TRACEPOINT,
diff --git a/libc/kernel/uapi/linux/can.h b/libc/kernel/uapi/linux/can.h
index 46eafc5..59fc31e 100644
--- a/libc/kernel/uapi/linux/can.h
+++ b/libc/kernel/uapi/linux/can.h
@@ -40,7 +40,7 @@
union {
__u8 len;
__u8 can_dlc;
- };
+ } __attribute__((packed));
__u8 __pad;
__u8 __res0;
__u8 len8_dlc;
diff --git a/libc/kernel/uapi/linux/ccs.h b/libc/kernel/uapi/linux/ccs.h
new file mode 100644
index 0000000..53c88af
--- /dev/null
+++ b/libc/kernel/uapi/linux/ccs.h
@@ -0,0 +1,30 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __UAPI_CCS_H__
+#define __UAPI_CCS_H__
+#include <linux/v4l2-controls.h>
+#define V4L2_CID_CCS_ANALOGUE_GAIN_M0 (V4L2_CID_USER_CCS_BASE + 1)
+#define V4L2_CID_CCS_ANALOGUE_GAIN_C0 (V4L2_CID_USER_CCS_BASE + 2)
+#define V4L2_CID_CCS_ANALOGUE_GAIN_M1 (V4L2_CID_USER_CCS_BASE + 3)
+#define V4L2_CID_CCS_ANALOGUE_GAIN_C1 (V4L2_CID_USER_CCS_BASE + 4)
+#define V4L2_CID_CCS_ANALOGUE_LINEAR_GAIN (V4L2_CID_USER_CCS_BASE + 5)
+#define V4L2_CID_CCS_ANALOGUE_EXPONENTIAL_GAIN (V4L2_CID_USER_CCS_BASE + 6)
+#define V4L2_CID_CCS_SHADING_CORRECTION (V4L2_CID_USER_CCS_BASE + 8)
+#define V4L2_CID_CCS_LUMINANCE_CORRECTION_LEVEL (V4L2_CID_USER_CCS_BASE + 9)
+#endif
diff --git a/libc/kernel/uapi/linux/cxl_mem.h b/libc/kernel/uapi/linux/cxl_mem.h
new file mode 100644
index 0000000..851bd79
--- /dev/null
+++ b/libc/kernel/uapi/linux/cxl_mem.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_CXL_MEM_H_
+#define _UAPI_CXL_MEM_H_
+#include <linux/types.h>
+#define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands)
+#define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command)
+#define CXL_CMDS ___C(INVALID, "Invalid Command"), ___C(IDENTIFY, "Identify Command"), ___C(RAW, "Raw device command"), ___C(GET_SUPPORTED_LOGS, "Get Supported Logs"), ___C(GET_FW_INFO, "Get FW Info"), ___C(GET_PARTITION_INFO, "Get Partition Information"), ___C(GET_LSA, "Get Label Storage Area"), ___C(GET_HEALTH_INFO, "Get Health Info"), ___C(GET_LOG, "Get Log"), ___C(MAX, "invalid / last command")
+#define ___C(a,b) CXL_MEM_COMMAND_ID_ ##a
+enum {
+ CXL_CMDS
+};
+#undef ___C
+#define ___C(a,b) { b }
+static const struct {
+ const char * name;
+} cxl_command_names[] = {
+ CXL_CMDS
+};
+#undef ___C
+struct cxl_command_info {
+ __u32 id;
+ __u32 flags;
+#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0)
+ __s32 size_in;
+ __s32 size_out;
+};
+struct cxl_mem_query_commands {
+ __u32 n_commands;
+ __u32 rsvd;
+ struct cxl_command_info __user commands[];
+};
+struct cxl_send_command {
+ __u32 id;
+ __u32 flags;
+ union {
+ struct {
+ __u16 opcode;
+ __u16 rsvd;
+ } raw;
+ __u32 rsvd;
+ };
+ __u32 retval;
+ struct {
+ __s32 size;
+ __u32 rsvd;
+ __u64 payload;
+ } in;
+ struct {
+ __s32 size;
+ __u32 rsvd;
+ __u64 payload;
+ } out;
+};
+#endif
diff --git a/libc/kernel/uapi/linux/devlink.h b/libc/kernel/uapi/linux/devlink.h
index 306557a..e6e006f 100644
--- a/libc/kernel/uapi/linux/devlink.h
+++ b/libc/kernel/uapi/linux/devlink.h
@@ -139,6 +139,7 @@
DEVLINK_PORT_FLAVOUR_PCI_VF,
DEVLINK_PORT_FLAVOUR_VIRTUAL,
DEVLINK_PORT_FLAVOUR_UNUSED,
+ DEVLINK_PORT_FLAVOUR_PCI_SF,
};
enum devlink_param_cmode {
DEVLINK_PARAM_CMODE_RUNTIME,
@@ -368,6 +369,7 @@
DEVLINK_ATTR_REMOTE_RELOAD_STATS,
DEVLINK_ATTR_RELOAD_ACTION_INFO,
DEVLINK_ATTR_RELOAD_ACTION_STATS,
+ DEVLINK_ATTR_PORT_PCI_SF_NUMBER,
__DEVLINK_ATTR_MAX,
DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
};
@@ -401,7 +403,17 @@
enum devlink_port_function_attr {
DEVLINK_PORT_FUNCTION_ATTR_UNSPEC,
DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR,
+ DEVLINK_PORT_FN_ATTR_STATE,
+ DEVLINK_PORT_FN_ATTR_OPSTATE,
__DEVLINK_PORT_FUNCTION_ATTR_MAX,
DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1
};
+enum devlink_port_fn_state {
+ DEVLINK_PORT_FN_STATE_INACTIVE,
+ DEVLINK_PORT_FN_STATE_ACTIVE,
+};
+enum devlink_port_fn_opstate {
+ DEVLINK_PORT_FN_OPSTATE_DETACHED,
+ DEVLINK_PORT_FN_OPSTATE_ATTACHED,
+};
#endif
diff --git a/libc/kernel/uapi/linux/dm-ioctl.h b/libc/kernel/uapi/linux/dm-ioctl.h
index bfa4cd3..4c0a9f0 100644
--- a/libc/kernel/uapi/linux/dm-ioctl.h
+++ b/libc/kernel/uapi/linux/dm-ioctl.h
@@ -104,9 +104,9 @@
#define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
#define DM_VERSION_MAJOR 4
-#define DM_VERSION_MINOR 43
+#define DM_VERSION_MINOR 44
#define DM_VERSION_PATCHLEVEL 0
-#define DM_VERSION_EXTRA "-ioctl(2020-10-01)"
+#define DM_VERSION_EXTRA "-ioctl(2021-02-01)"
#define DM_READONLY_FLAG (1 << 0)
#define DM_SUSPEND_FLAG (1 << 1)
#define DM_PERSISTENT_DEV_FLAG (1 << 3)
diff --git a/libc/kernel/uapi/linux/ethtool_netlink.h b/libc/kernel/uapi/linux/ethtool_netlink.h
index 95761dd..67091a1 100644
--- a/libc/kernel/uapi/linux/ethtool_netlink.h
+++ b/libc/kernel/uapi/linux/ethtool_netlink.h
@@ -178,6 +178,7 @@
ETHTOOL_A_LINKMODES_DUPLEX,
ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG,
ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE,
+ ETHTOOL_A_LINKMODES_LANES,
__ETHTOOL_A_LINKMODES_CNT,
ETHTOOL_A_LINKMODES_MAX = __ETHTOOL_A_LINKMODES_CNT - 1
};
diff --git a/libc/kernel/uapi/linux/fsl_mc.h b/libc/kernel/uapi/linux/fsl_mc.h
new file mode 100644
index 0000000..721da93
--- /dev/null
+++ b/libc/kernel/uapi/linux/fsl_mc.h
@@ -0,0 +1,30 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_FSL_MC_H_
+#define _UAPI_FSL_MC_H_
+#include <linux/types.h>
+#define MC_CMD_NUM_OF_PARAMS 7
+struct fsl_mc_command {
+ __le64 header;
+ __le64 params[MC_CMD_NUM_OF_PARAMS];
+};
+#define FSL_MC_SEND_CMD_IOCTL_TYPE 'R'
+#define FSL_MC_SEND_CMD_IOCTL_SEQ 0xE0
+#define FSL_MC_SEND_MC_COMMAND _IOWR(FSL_MC_SEND_CMD_IOCTL_TYPE, FSL_MC_SEND_CMD_IOCTL_SEQ, struct fsl_mc_command)
+#endif
diff --git a/libc/kernel/uapi/linux/fsverity.h b/libc/kernel/uapi/linux/fsverity.h
index da8b99d..ff1603c 100644
--- a/libc/kernel/uapi/linux/fsverity.h
+++ b/libc/kernel/uapi/linux/fsverity.h
@@ -55,6 +55,17 @@
__le16 digest_size;
__u8 digest[];
};
+#define FS_VERITY_METADATA_TYPE_MERKLE_TREE 1
+#define FS_VERITY_METADATA_TYPE_DESCRIPTOR 2
+#define FS_VERITY_METADATA_TYPE_SIGNATURE 3
+struct fsverity_read_metadata_arg {
+ __u64 metadata_type;
+ __u64 offset;
+ __u64 length;
+ __u64 buf_ptr;
+ __u64 __reserved;
+};
#define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg)
#define FS_IOC_MEASURE_VERITY _IOWR('f', 134, struct fsverity_digest)
+#define FS_IOC_READ_VERITY_METADATA _IOWR('f', 135, struct fsverity_read_metadata_arg)
#endif
diff --git a/libc/kernel/uapi/linux/gfs2_ondisk.h b/libc/kernel/uapi/linux/gfs2_ondisk.h
index a8fb59e..1ce4278 100644
--- a/libc/kernel/uapi/linux/gfs2_ondisk.h
+++ b/libc/kernel/uapi/linux/gfs2_ondisk.h
@@ -45,7 +45,7 @@
#define GFS2_FORMAT_RI 1100
#define GFS2_FORMAT_DE 1200
#define GFS2_FORMAT_QU 1500
-#define GFS2_FORMAT_FS 1801
+#define GFS2_FORMAT_FS 1802
#define GFS2_FORMAT_MULTI 1900
struct gfs2_inum {
__be64 no_formal_ino;
@@ -260,7 +260,8 @@
#define GFS2_EATYPE_USR 1
#define GFS2_EATYPE_SYS 2
#define GFS2_EATYPE_SECURITY 3
-#define GFS2_EATYPE_LAST 3
+#define GFS2_EATYPE_TRUSTED 4
+#define GFS2_EATYPE_LAST 4
#define GFS2_EATYPE_VALID(x) ((x) <= GFS2_EATYPE_LAST)
#define GFS2_EAFLAG_LAST 0x01
struct gfs2_ea_header {
diff --git a/libc/kernel/uapi/linux/i2c.h b/libc/kernel/uapi/linux/i2c.h
index dc1e96a..fe578e8 100644
--- a/libc/kernel/uapi/linux/i2c.h
+++ b/libc/kernel/uapi/linux/i2c.h
@@ -60,6 +60,7 @@
#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_PEC)
+#define I2C_FUNC_SMBUS_EMUL_ALL (I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL)
#define I2C_SMBUS_BLOCK_MAX 32
union i2c_smbus_data {
__u8 byte;
diff --git a/libc/kernel/uapi/linux/idxd.h b/libc/kernel/uapi/linux/idxd.h
index 8724149..4f1282e 100644
--- a/libc/kernel/uapi/linux/idxd.h
+++ b/libc/kernel/uapi/linux/idxd.h
@@ -231,8 +231,8 @@
uint32_t invalid_flags : 24;
uint32_t rsvd2 : 8;
};
- uint16_t delta_rec_size;
- uint16_t crc_val;
+ uint32_t delta_rec_size;
+ uint32_t crc_val;
struct {
uint32_t dif_chk_ref_tag;
uint16_t dif_chk_app_tag_mask;
diff --git a/libc/kernel/uapi/linux/if_bonding.h b/libc/kernel/uapi/linux/if_bonding.h
index 0079f30..60abfde 100644
--- a/libc/kernel/uapi/linux/if_bonding.h
+++ b/libc/kernel/uapi/linux/if_bonding.h
@@ -50,6 +50,7 @@
#define BOND_XMIT_POLICY_LAYER23 2
#define BOND_XMIT_POLICY_ENCAP23 3
#define BOND_XMIT_POLICY_ENCAP34 4
+#define BOND_XMIT_POLICY_VLAN_SRCMAC 5
#define LACP_STATE_LACP_ACTIVITY 0x1
#define LACP_STATE_LACP_TIMEOUT 0x2
#define LACP_STATE_AGGREGATION 0x4
diff --git a/libc/kernel/uapi/linux/if_link.h b/libc/kernel/uapi/linux/if_link.h
index 3db8a4f..2a5ba5a 100644
--- a/libc/kernel/uapi/linux/if_link.h
+++ b/libc/kernel/uapi/linux/if_link.h
@@ -282,6 +282,8 @@
IFLA_BRPORT_BACKUP_PORT,
IFLA_BRPORT_MRP_RING_OPEN,
IFLA_BRPORT_MRP_IN_OPEN,
+ IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
+ IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
__IFLA_BRPORT_MAX
};
#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
diff --git a/libc/kernel/uapi/linux/incrementalfs.h b/libc/kernel/uapi/linux/incrementalfs.h
index 65d825c..622a998 100644
--- a/libc/kernel/uapi/linux/incrementalfs.h
+++ b/libc/kernel/uapi/linux/incrementalfs.h
@@ -23,7 +23,7 @@
#include <linux/types.h>
#include <linux/xattr.h>
#define INCFS_NAME "incremental-fs"
-#define INCFS_MAGIC_NUMBER (unsigned long) (0x5346434e49ul)
+#define INCFS_MAGIC_NUMBER (0x5346434e49ul & ULONG_MAX)
#define INCFS_DATA_FILE_BLOCK_SIZE 4096
#define INCFS_HEADER_VER 1
#define INCFS_MAX_HASH_SIZE 32
@@ -50,6 +50,7 @@
#define INCFS_IOC_GET_BLOCK_COUNT _IOR(INCFS_IOCTL_BASE_CODE, 36, struct incfs_get_block_count_args)
#define INCFS_IOC_GET_READ_TIMEOUTS _IOR(INCFS_IOCTL_BASE_CODE, 37, struct incfs_get_read_timeouts_args)
#define INCFS_IOC_SET_READ_TIMEOUTS _IOW(INCFS_IOCTL_BASE_CODE, 38, struct incfs_set_read_timeouts_args)
+#define INCFS_IOC_GET_LAST_READ_ERROR _IOW(INCFS_IOCTL_BASE_CODE, 39, struct incfs_get_last_read_error_args)
#define INCFS_FEATURE_FLAG_COREFS "corefs"
#define INCFS_FEATURE_FLAG_ZSTD "zstd"
#define INCFS_FEATURE_FLAG_V2 "v2"
@@ -165,4 +166,11 @@
__aligned_u64 timeouts_array;
__u32 timeouts_array_size;
};
+struct incfs_get_last_read_error_args {
+ incfs_uuid_t file_id_out;
+ __u64 time_us_out;
+ __u32 page_out;
+ __u32 errno_out;
+ __u64 reserved;
+};
#endif
diff --git a/libc/kernel/uapi/linux/io_uring.h b/libc/kernel/uapi/linux/io_uring.h
index ea9fcdb..fa59d39 100644
--- a/libc/kernel/uapi/linux/io_uring.h
+++ b/libc/kernel/uapi/linux/io_uring.h
@@ -191,6 +191,7 @@
#define IORING_FEAT_POLL_32BITS (1U << 6)
#define IORING_FEAT_SQPOLL_NONFIXED (1U << 7)
#define IORING_FEAT_EXT_ARG (1U << 8)
+#define IORING_FEAT_NATIVE_WORKERS (1U << 9)
enum {
IORING_REGISTER_BUFFERS = 0,
IORING_UNREGISTER_BUFFERS = 1,
@@ -212,6 +213,12 @@
__u32 resv;
__aligned_u64 fds;
};
+struct io_uring_rsrc_update {
+ __u32 offset;
+ __u32 resv;
+ __aligned_u64 data;
+};
+#define IORING_REGISTER_FILES_SKIP (- 2)
#define IO_URING_OP_SUPPORTED (1U << 0)
struct io_uring_probe_op {
__u8 op;
diff --git a/libc/kernel/uapi/linux/ipv6.h b/libc/kernel/uapi/linux/ipv6.h
index 7cd6cb0..438cacc 100644
--- a/libc/kernel/uapi/linux/ipv6.h
+++ b/libc/kernel/uapi/linux/ipv6.h
@@ -143,6 +143,7 @@
DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN,
DEVCONF_NDISC_TCLASS,
DEVCONF_RPL_SEG_ENABLED,
+ DEVCONF_RA_DEFRTR_METRIC,
DEVCONF_MAX
};
#endif
diff --git a/libc/kernel/uapi/linux/kvm.h b/libc/kernel/uapi/linux/kvm.h
index 1153458..81fa779 100644
--- a/libc/kernel/uapi/linux/kvm.h
+++ b/libc/kernel/uapi/linux/kvm.h
@@ -164,6 +164,19 @@
} syndbg;
} u;
};
+struct kvm_xen_exit {
+#define KVM_EXIT_XEN_HCALL 1
+ __u32 type;
+ union {
+ struct {
+ __u32 longmode;
+ __u32 cpl;
+ __u64 input;
+ __u64 result;
+ __u64 params[6];
+ } hcall;
+ } u;
+};
#define KVM_S390_GET_SKEYS_NONE 1
#define KVM_S390_SKEYS_MAX 1048576
#define KVM_EXIT_UNKNOWN 0
@@ -199,6 +212,8 @@
#define KVM_EXIT_X86_WRMSR 30
#define KVM_EXIT_DIRTY_RING_FULL 31
#define KVM_EXIT_AP_RESET_HOLD 32
+#define KVM_EXIT_X86_BUS_LOCK 33
+#define KVM_EXIT_XEN 34
#define KVM_INTERNAL_ERROR_EMULATION 1
#define KVM_INTERNAL_ERROR_SIMUL_EX 2
#define KVM_INTERNAL_ERROR_DELIVERY_EV 3
@@ -336,6 +351,7 @@
__u32 index;
__u64 data;
} msr;
+ struct kvm_xen_exit xen;
char padding[256];
};
#define SYNC_REGS_SIZE_BYTES 2048
@@ -836,6 +852,8 @@
#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
#define KVM_CAP_SYS_HYPERV_CPUID 191
#define KVM_CAP_DIRTY_LOG_RING 192
+#define KVM_CAP_X86_BUS_LOCK_EXIT 193
+#define KVM_CAP_PPC_DAWR1 194
#ifdef KVM_CAP_IRQ_ROUTING
struct kvm_irq_routing_irqchip {
__u32 irqchip;
@@ -896,6 +914,10 @@
};
#endif
#ifdef KVM_CAP_XEN_HVM
+#define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0)
+#define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1)
+#define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2)
+#define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3)
struct kvm_xen_hvm_config {
__u32 flags;
__u32 msr;
@@ -1189,6 +1211,47 @@
#define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
#define KVM_X86_SET_MSR_FILTER _IOW(KVMIO, 0xc6, struct kvm_msr_filter)
#define KVM_RESET_DIRTY_RINGS _IO(KVMIO, 0xc7)
+#define KVM_XEN_HVM_GET_ATTR _IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr)
+#define KVM_XEN_HVM_SET_ATTR _IOW(KVMIO, 0xc9, struct kvm_xen_hvm_attr)
+struct kvm_xen_hvm_attr {
+ __u16 type;
+ __u16 pad[3];
+ union {
+ __u8 long_mode;
+ __u8 vector;
+ struct {
+ __u64 gfn;
+ } shared_info;
+ __u64 pad[8];
+ } u;
+};
+#define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0
+#define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1
+#define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2
+#define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
+#define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr)
+struct kvm_xen_vcpu_attr {
+ __u16 type;
+ __u16 pad[3];
+ union {
+ __u64 gpa;
+ __u64 pad[8];
+ struct {
+ __u64 state;
+ __u64 state_entry_time;
+ __u64 time_running;
+ __u64 time_runnable;
+ __u64 time_blocked;
+ __u64 time_offline;
+ } runstate;
+ } u;
+};
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 0x1
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 0x2
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5
enum sev_cmd_id {
KVM_SEV_INIT = 0,
KVM_SEV_ES_INIT,
@@ -1210,6 +1273,7 @@
KVM_SEV_DBG_DECRYPT,
KVM_SEV_DBG_ENCRYPT,
KVM_SEV_CERT_EXPORT,
+ KVM_SEV_GET_ATTESTATION_REPORT,
KVM_SEV_NR_MAX,
};
struct kvm_sev_cmd {
@@ -1252,6 +1316,11 @@
__u64 dst_uaddr;
__u32 len;
};
+struct kvm_sev_attestation_report {
+ __u8 mnonce[16];
+ __u64 uaddr;
+ __u32 len;
+};
#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
#define KVM_DEV_ASSIGN_MASK_INTX (1 << 2)
@@ -1320,4 +1389,6 @@
__u32 slot;
__u64 offset;
};
+#define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
+#define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
#endif
diff --git a/libc/kernel/uapi/linux/l2tp.h b/libc/kernel/uapi/linux/l2tp.h
index c65f7a9..a054819 100644
--- a/libc/kernel/uapi/linux/l2tp.h
+++ b/libc/kernel/uapi/linux/l2tp.h
@@ -104,6 +104,7 @@
L2TP_ATTR_RX_ERRORS,
L2TP_ATTR_STATS_PAD,
L2TP_ATTR_RX_COOKIE_DISCARDS,
+ L2TP_ATTR_RX_INVALID,
__L2TP_ATTR_STATS_MAX,
};
#define L2TP_ATTR_STATS_MAX (__L2TP_ATTR_STATS_MAX - 1)
diff --git a/libc/kernel/uapi/linux/media.h b/libc/kernel/uapi/linux/media.h
index fe29568..5c8efcd 100644
--- a/libc/kernel/uapi/linux/media.h
+++ b/libc/kernel/uapi/linux/media.h
@@ -61,6 +61,7 @@
#define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006)
#define MEDIA_ENT_F_PROC_VIDEO_ENCODER (MEDIA_ENT_F_BASE + 0x4007)
#define MEDIA_ENT_F_PROC_VIDEO_DECODER (MEDIA_ENT_F_BASE + 0x4008)
+#define MEDIA_ENT_F_PROC_VIDEO_ISP (MEDIA_ENT_F_BASE + 0x4009)
#define MEDIA_ENT_F_VID_MUX (MEDIA_ENT_F_BASE + 0x5001)
#define MEDIA_ENT_F_VID_IF_BRIDGE (MEDIA_ENT_F_BASE + 0x5002)
#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
diff --git a/libc/kernel/uapi/linux/mempolicy.h b/libc/kernel/uapi/linux/mempolicy.h
index 6f721f6..5425c0e 100644
--- a/libc/kernel/uapi/linux/mempolicy.h
+++ b/libc/kernel/uapi/linux/mempolicy.h
@@ -29,7 +29,8 @@
};
#define MPOL_F_STATIC_NODES (1 << 15)
#define MPOL_F_RELATIVE_NODES (1 << 14)
-#define MPOL_MODE_FLAGS (MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES)
+#define MPOL_F_NUMA_BALANCING (1 << 13)
+#define MPOL_MODE_FLAGS (MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES | MPOL_F_NUMA_BALANCING)
#define MPOL_F_NODE (1 << 0)
#define MPOL_F_ADDR (1 << 1)
#define MPOL_F_MEMS_ALLOWED (1 << 2)
diff --git a/libc/kernel/uapi/linux/misc/bcm_vk.h b/libc/kernel/uapi/linux/misc/bcm_vk.h
new file mode 100644
index 0000000..b1b966d
--- /dev/null
+++ b/libc/kernel/uapi/linux/misc/bcm_vk.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __UAPI_LINUX_MISC_BCM_VK_H
+#define __UAPI_LINUX_MISC_BCM_VK_H
+#include <linux/ioctl.h>
+#include <linux/types.h>
+#define BCM_VK_MAX_FILENAME 64
+struct vk_image {
+ __u32 type;
+#define VK_IMAGE_TYPE_BOOT1 1
+#define VK_IMAGE_TYPE_BOOT2 2
+ __u8 filename[BCM_VK_MAX_FILENAME];
+};
+struct vk_reset {
+ __u32 arg1;
+ __u32 arg2;
+};
+#define VK_MAGIC 0x5e
+#define VK_IOCTL_LOAD_IMAGE _IOW(VK_MAGIC, 0x2, struct vk_image)
+#define VK_IOCTL_RESET _IOW(VK_MAGIC, 0x4, struct vk_reset)
+#define VK_BAR_FWSTS 0x41c
+#define VK_BAR_COP_FWSTS 0x428
+#define VK_FWSTS_RELOCATION_ENTRY (1UL << 0)
+#define VK_FWSTS_RELOCATION_EXIT (1UL << 1)
+#define VK_FWSTS_INIT_START (1UL << 2)
+#define VK_FWSTS_ARCH_INIT_DONE (1UL << 3)
+#define VK_FWSTS_PRE_KNL1_INIT_DONE (1UL << 4)
+#define VK_FWSTS_PRE_KNL2_INIT_DONE (1UL << 5)
+#define VK_FWSTS_POST_KNL_INIT_DONE (1UL << 6)
+#define VK_FWSTS_INIT_DONE (1UL << 7)
+#define VK_FWSTS_APP_INIT_START (1UL << 8)
+#define VK_FWSTS_APP_INIT_DONE (1UL << 9)
+#define VK_FWSTS_MASK 0xffffffff
+#define VK_FWSTS_READY (VK_FWSTS_INIT_START | VK_FWSTS_ARCH_INIT_DONE | VK_FWSTS_PRE_KNL1_INIT_DONE | VK_FWSTS_PRE_KNL2_INIT_DONE | VK_FWSTS_POST_KNL_INIT_DONE | VK_FWSTS_INIT_DONE | VK_FWSTS_APP_INIT_START | VK_FWSTS_APP_INIT_DONE)
+#define VK_FWSTS_APP_DEINIT_START (1UL << 23)
+#define VK_FWSTS_APP_DEINIT_DONE (1UL << 24)
+#define VK_FWSTS_DRV_DEINIT_START (1UL << 25)
+#define VK_FWSTS_DRV_DEINIT_DONE (1UL << 26)
+#define VK_FWSTS_RESET_DONE (1UL << 27)
+#define VK_FWSTS_DEINIT_TRIGGERED (VK_FWSTS_APP_DEINIT_START | VK_FWSTS_APP_DEINIT_DONE | VK_FWSTS_DRV_DEINIT_START | VK_FWSTS_DRV_DEINIT_DONE)
+#define VK_FWSTS_RESET_REASON_SHIFT 28
+#define VK_FWSTS_RESET_REASON_MASK (0xf << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_SYS_PWRUP (0x0 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_MBOX_DB (0x1 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_M7_WDOG (0x2 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_TEMP (0x3 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_PCI_FLR (0x4 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_PCI_HOT (0x5 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_PCI_WARM (0x6 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_PCI_COLD (0x7 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_L1 (0x8 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_L0 (0x9 << VK_FWSTS_RESET_REASON_SHIFT)
+#define VK_FWSTS_RESET_UNKNOWN (0xf << VK_FWSTS_RESET_REASON_SHIFT)
+#endif
diff --git a/libc/kernel/uapi/linux/mount.h b/libc/kernel/uapi/linux/mount.h
index 99c2d98..5a112c9 100644
--- a/libc/kernel/uapi/linux/mount.h
+++ b/libc/kernel/uapi/linux/mount.h
@@ -18,6 +18,7 @@
****************************************************************************/
#ifndef _UAPI_LINUX_MOUNT_H
#define _UAPI_LINUX_MOUNT_H
+#include <linux/types.h>
#define MS_RDONLY 1
#define MS_NOSUID 2
#define MS_NODEV 4
@@ -87,4 +88,12 @@
#define MOUNT_ATTR_NOATIME 0x00000010
#define MOUNT_ATTR_STRICTATIME 0x00000020
#define MOUNT_ATTR_NODIRATIME 0x00000080
+#define MOUNT_ATTR_IDMAP 0x00100000
+struct mount_attr {
+ __u64 attr_set;
+ __u64 attr_clr;
+ __u64 propagation;
+ __u64 userns_fd;
+};
+#define MOUNT_ATTR_SIZE_VER0 32
#endif
diff --git a/libc/kernel/uapi/linux/mptcp.h b/libc/kernel/uapi/linux/mptcp.h
index deaa1bf..b15adf5 100644
--- a/libc/kernel/uapi/linux/mptcp.h
+++ b/libc/kernel/uapi/linux/mptcp.h
@@ -47,6 +47,7 @@
#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1)
#define MPTCP_PM_NAME "mptcp_pm"
#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"
+#define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events"
#define MPTCP_PM_VER 0x1
enum {
MPTCP_PM_ATTR_UNSPEC,
@@ -79,6 +80,7 @@
MPTCP_PM_CMD_FLUSH_ADDRS,
MPTCP_PM_CMD_SET_LIMITS,
MPTCP_PM_CMD_GET_LIMITS,
+ MPTCP_PM_CMD_SET_FLAGS,
__MPTCP_PM_CMD_AFTER_LAST
};
#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)
@@ -95,5 +97,38 @@
__u64 mptcpi_write_seq;
__u64 mptcpi_snd_una;
__u64 mptcpi_rcv_nxt;
+ __u8 mptcpi_local_addr_used;
+ __u8 mptcpi_local_addr_max;
};
+enum mptcp_event_type {
+ MPTCP_EVENT_UNSPEC = 0,
+ MPTCP_EVENT_CREATED = 1,
+ MPTCP_EVENT_ESTABLISHED = 2,
+ MPTCP_EVENT_CLOSED = 3,
+ MPTCP_EVENT_ANNOUNCED = 6,
+ MPTCP_EVENT_REMOVED = 7,
+ MPTCP_EVENT_SUB_ESTABLISHED = 10,
+ MPTCP_EVENT_SUB_CLOSED = 11,
+ MPTCP_EVENT_SUB_PRIORITY = 13,
+};
+enum mptcp_event_attr {
+ MPTCP_ATTR_UNSPEC = 0,
+ MPTCP_ATTR_TOKEN,
+ MPTCP_ATTR_FAMILY,
+ MPTCP_ATTR_LOC_ID,
+ MPTCP_ATTR_REM_ID,
+ MPTCP_ATTR_SADDR4,
+ MPTCP_ATTR_SADDR6,
+ MPTCP_ATTR_DADDR4,
+ MPTCP_ATTR_DADDR6,
+ MPTCP_ATTR_SPORT,
+ MPTCP_ATTR_DPORT,
+ MPTCP_ATTR_BACKUP,
+ MPTCP_ATTR_ERROR,
+ MPTCP_ATTR_FLAGS,
+ MPTCP_ATTR_TIMEOUT,
+ MPTCP_ATTR_IF_IDX,
+ __MPTCP_ATTR_AFTER_LAST
+};
+#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1)
#endif
diff --git a/libc/kernel/uapi/linux/netfilter/nf_tables.h b/libc/kernel/uapi/linux/netfilter/nf_tables.h
index b35dd65..0023a94 100644
--- a/libc/kernel/uapi/linux/netfilter/nf_tables.h
+++ b/libc/kernel/uapi/linux/netfilter/nf_tables.h
@@ -105,7 +105,9 @@
#define NFTA_HOOK_MAX (__NFTA_HOOK_MAX - 1)
enum nft_table_flags {
NFT_TABLE_F_DORMANT = 0x1,
+ NFT_TABLE_F_OWNER = 0x2,
};
+#define NFT_TABLE_F_MASK (NFT_TABLE_F_DORMANT | NFT_TABLE_F_OWNER)
enum nft_table_attributes {
NFTA_TABLE_UNSPEC,
NFTA_TABLE_NAME,
@@ -114,6 +116,7 @@
NFTA_TABLE_HANDLE,
NFTA_TABLE_PAD,
NFTA_TABLE_USERDATA,
+ NFTA_TABLE_OWNER,
__NFTA_TABLE_MAX
};
#define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
diff --git a/libc/kernel/uapi/linux/netfilter/nfnetlink_cthelper.h b/libc/kernel/uapi/linux/netfilter/nfnetlink_cthelper.h
index 0a8cd45..e8c2825 100644
--- a/libc/kernel/uapi/linux/netfilter/nfnetlink_cthelper.h
+++ b/libc/kernel/uapi/linux/netfilter/nfnetlink_cthelper.h
@@ -20,7 +20,7 @@
#define _NFNL_CTHELPER_H_
#define NFCT_HELPER_STATUS_DISABLED 0
#define NFCT_HELPER_STATUS_ENABLED 1
-enum nfnl_acct_msg_types {
+enum nfnl_cthelper_msg_types {
NFNL_MSG_CTHELPER_NEW,
NFNL_MSG_CTHELPER_GET,
NFNL_MSG_CTHELPER_DEL,
diff --git a/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h b/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h
index a59ae09..f4defb6 100644
--- a/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h
+++ b/libc/kernel/uapi/linux/netfilter/xt_IDLETIMER.h
@@ -21,13 +21,9 @@
#include <linux/types.h>
#define MAX_IDLETIMER_LABEL_SIZE 28
#define XT_IDLETIMER_ALARM 0x01
-#define NLMSG_MAX_SIZE 64
-#define NL_EVENT_TYPE_INACTIVE 0
-#define NL_EVENT_TYPE_ACTIVE 1
struct idletimer_tg_info {
__u32 timeout;
char label[MAX_IDLETIMER_LABEL_SIZE];
- __u8 send_nl_msg;
struct idletimer_tg * timer __attribute__((aligned(8)));
};
struct idletimer_tg_info_v1 {
diff --git a/libc/kernel/uapi/linux/nfs3.h b/libc/kernel/uapi/linux/nfs3.h
index 3972d0b..af0d668 100644
--- a/libc/kernel/uapi/linux/nfs3.h
+++ b/libc/kernel/uapi/linux/nfs3.h
@@ -67,6 +67,11 @@
NF3FIFO = 7,
NF3BAD = 8
};
+enum nfs3_time_how {
+ DONT_CHANGE = 0,
+ SET_TO_SERVER_TIME = 1,
+ SET_TO_CLIENT_TIME = 2,
+};
struct nfs3_fh {
unsigned short size;
unsigned char data[NFS3_FHSIZE];
diff --git a/libc/kernel/uapi/linux/nl80211.h b/libc/kernel/uapi/linux/nl80211.h
index 0632ff2..5181160 100644
--- a/libc/kernel/uapi/linux/nl80211.h
+++ b/libc/kernel/uapi/linux/nl80211.h
@@ -495,6 +495,7 @@
NL80211_ATTR_SAE_PWE,
NL80211_ATTR_RECONNECT_REQUESTED,
NL80211_ATTR_SAR_SPEC,
+ NL80211_ATTR_DISABLE_HE,
__NL80211_ATTR_AFTER_LAST,
NUM_NL80211_ATTR = __NL80211_ATTR_AFTER_LAST,
NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
diff --git a/libc/kernel/uapi/linux/openat2.h b/libc/kernel/uapi/linux/openat2.h
index 27136af..d397a00 100644
--- a/libc/kernel/uapi/linux/openat2.h
+++ b/libc/kernel/uapi/linux/openat2.h
@@ -29,4 +29,5 @@
#define RESOLVE_NO_SYMLINKS 0x04
#define RESOLVE_BENEATH 0x08
#define RESOLVE_IN_ROOT 0x10
+#define RESOLVE_CACHED 0x20
#endif
diff --git a/libc/kernel/uapi/linux/perf_event.h b/libc/kernel/uapi/linux/perf_event.h
index be32b51..b09c5d8 100644
--- a/libc/kernel/uapi/linux/perf_event.h
+++ b/libc/kernel/uapi/linux/perf_event.h
@@ -103,9 +103,11 @@
PERF_SAMPLE_CGROUP = 1U << 21,
PERF_SAMPLE_DATA_PAGE_SIZE = 1U << 22,
PERF_SAMPLE_CODE_PAGE_SIZE = 1U << 23,
- PERF_SAMPLE_MAX = 1U << 24,
+ PERF_SAMPLE_WEIGHT_STRUCT = 1U << 24,
+ PERF_SAMPLE_MAX = 1U << 25,
__PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63,
};
+#define PERF_SAMPLE_WEIGHT_TYPE (PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT)
enum perf_branch_sample_type_shift {
PERF_SAMPLE_BRANCH_USER_SHIFT = 0,
PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 1,
@@ -205,7 +207,7 @@
};
__u64 sample_type;
__u64 read_format;
- __u64 disabled : 1, inherit : 1, pinned : 1, exclusive : 1, exclude_user : 1, exclude_kernel : 1, exclude_hv : 1, exclude_idle : 1, mmap : 1, comm : 1, freq : 1, inherit_stat : 1, enable_on_exec : 1, task : 1, watermark : 1, precise_ip : 2, mmap_data : 1, sample_id_all : 1, exclude_host : 1, exclude_guest : 1, exclude_callchain_kernel : 1, exclude_callchain_user : 1, mmap2 : 1, comm_exec : 1, use_clockid : 1, context_switch : 1, write_backward : 1, namespaces : 1, ksymbol : 1, bpf_event : 1, aux_output : 1, cgroup : 1, text_poke : 1, __reserved_1 : 30;
+ __u64 disabled : 1, inherit : 1, pinned : 1, exclusive : 1, exclude_user : 1, exclude_kernel : 1, exclude_hv : 1, exclude_idle : 1, mmap : 1, comm : 1, freq : 1, inherit_stat : 1, enable_on_exec : 1, task : 1, watermark : 1, precise_ip : 2, mmap_data : 1, sample_id_all : 1, exclude_host : 1, exclude_guest : 1, exclude_callchain_kernel : 1, exclude_callchain_user : 1, mmap2 : 1, comm_exec : 1, use_clockid : 1, context_switch : 1, write_backward : 1, namespaces : 1, ksymbol : 1, bpf_event : 1, aux_output : 1, cgroup : 1, text_poke : 1, build_id : 1, __reserved_1 : 29;
union {
__u32 wakeup_events;
__u32 wakeup_watermark;
@@ -301,6 +303,7 @@
#define PERF_RECORD_MISC_SWITCH_OUT (1 << 13)
#define PERF_RECORD_MISC_EXACT_IP (1 << 14)
#define PERF_RECORD_MISC_SWITCH_OUT_PREEMPT (1 << 14)
+#define PERF_RECORD_MISC_MMAP_BUILD_ID (1 << 14)
#define PERF_RECORD_MISC_EXT_RESERVED (1 << 15)
struct perf_event_header {
__u32 type;
@@ -380,14 +383,14 @@
union perf_mem_data_src {
__u64 val;
struct {
- __u64 mem_op : 5, mem_lvl : 14, mem_snoop : 5, mem_lock : 2, mem_dtlb : 7, mem_lvl_num : 4, mem_remote : 1, mem_snoopx : 2, mem_rsvd : 24;
+ __u64 mem_op : 5, mem_lvl : 14, mem_snoop : 5, mem_lock : 2, mem_dtlb : 7, mem_lvl_num : 4, mem_remote : 1, mem_snoopx : 2, mem_blk : 3, mem_rsvd : 21;
};
};
#elif defined(__BIG_ENDIAN_BITFIELD)
union perf_mem_data_src {
__u64 val;
struct {
- __u64 mem_rsvd : 24, mem_snoopx : 2, mem_remote : 1, mem_lvl_num : 4, mem_dtlb : 7, mem_lock : 2, mem_snoop : 5, mem_lvl : 14, mem_op : 5;
+ __u64 mem_rsvd : 21, mem_blk : 3, mem_snoopx : 2, mem_remote : 1, mem_lvl_num : 4, mem_dtlb : 7, mem_lock : 2, mem_snoop : 5, mem_lvl : 14, mem_op : 5;
};
};
#else
@@ -445,10 +448,32 @@
#define PERF_MEM_TLB_WK 0x20
#define PERF_MEM_TLB_OS 0x40
#define PERF_MEM_TLB_SHIFT 26
+#define PERF_MEM_BLK_NA 0x01
+#define PERF_MEM_BLK_DATA 0x02
+#define PERF_MEM_BLK_ADDR 0x04
+#define PERF_MEM_BLK_SHIFT 40
#define PERF_MEM_S(a,s) (((__u64) PERF_MEM_ ##a ##_ ##s) << PERF_MEM_ ##a ##_SHIFT)
struct perf_branch_entry {
__u64 from;
__u64 to;
__u64 mispred : 1, predicted : 1, in_tx : 1, abort : 1, cycles : 16, type : 4, reserved : 40;
};
+union perf_sample_weight {
+ __u64 full;
+#ifdef __LITTLE_ENDIAN_BITFIELD
+ struct {
+ __u32 var1_dw;
+ __u16 var2_w;
+ __u16 var3_w;
+ };
+#elif defined(__BIG_ENDIAN_BITFIELD)
+ struct {
+ __u16 var3_w;
+ __u16 var2_w;
+ __u32 var1_dw;
+ };
+#else
+#error "Unknown endianness"
+#endif
+};
#endif
diff --git a/libc/kernel/uapi/linux/pkt_cls.h b/libc/kernel/uapi/linux/pkt_cls.h
index 62c2274..45dca35 100644
--- a/libc/kernel/uapi/linux/pkt_cls.h
+++ b/libc/kernel/uapi/linux/pkt_cls.h
@@ -462,6 +462,9 @@
TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED = 1 << 1,
TCA_FLOWER_KEY_CT_FLAGS_RELATED = 1 << 2,
TCA_FLOWER_KEY_CT_FLAGS_TRACKED = 1 << 3,
+ TCA_FLOWER_KEY_CT_FLAGS_INVALID = 1 << 4,
+ TCA_FLOWER_KEY_CT_FLAGS_REPLY = 1 << 5,
+ __TCA_FLOWER_KEY_CT_FLAGS_MAX,
};
enum {
TCA_FLOWER_KEY_ENC_OPTS_UNSPEC,
diff --git a/libc/kernel/uapi/linux/pkt_sched.h b/libc/kernel/uapi/linux/pkt_sched.h
index 7c16d3c..d0541fc 100644
--- a/libc/kernel/uapi/linux/pkt_sched.h
+++ b/libc/kernel/uapi/linux/pkt_sched.h
@@ -306,6 +306,7 @@
TCA_HTB_RATE64,
TCA_HTB_CEIL64,
TCA_HTB_PAD,
+ TCA_HTB_OFFLOAD,
__TCA_HTB_MAX,
};
#define TCA_HTB_MAX (__TCA_HTB_MAX - 1)
diff --git a/libc/kernel/uapi/linux/psample.h b/libc/kernel/uapi/linux/psample.h
index 1f8b325..dc67445 100644
--- a/libc/kernel/uapi/linux/psample.h
+++ b/libc/kernel/uapi/linux/psample.h
@@ -26,8 +26,8 @@
PSAMPLE_ATTR_GROUP_SEQ,
PSAMPLE_ATTR_SAMPLE_RATE,
PSAMPLE_ATTR_DATA,
- PSAMPLE_ATTR_TUNNEL,
PSAMPLE_ATTR_GROUP_REFCOUNT,
+ PSAMPLE_ATTR_TUNNEL,
__PSAMPLE_ATTR_MAX
};
enum psample_command {
diff --git a/libc/kernel/uapi/linux/rfkill.h b/libc/kernel/uapi/linux/rfkill.h
index 4e72938..6020baf 100644
--- a/libc/kernel/uapi/linux/rfkill.h
+++ b/libc/kernel/uapi/linux/rfkill.h
@@ -50,9 +50,16 @@
__u8 op;
__u8 soft;
__u8 hard;
+} __attribute__((packed));
+struct rfkill_event_ext {
+ __u32 idx;
+ __u8 type;
+ __u8 op;
+ __u8 soft;
+ __u8 hard;
__u8 hard_block_reasons;
} __attribute__((packed));
-#define RFKILL_EVENT_SIZE_V1 8
+#define RFKILL_EVENT_SIZE_V1 sizeof(struct rfkill_event)
#define RFKILL_IOC_MAGIC 'R'
#define RFKILL_IOC_NOINPUT 1
#define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT)
diff --git a/libc/kernel/uapi/linux/rtc.h b/libc/kernel/uapi/linux/rtc.h
index 8e70eba..7f38483 100644
--- a/libc/kernel/uapi/linux/rtc.h
+++ b/libc/kernel/uapi/linux/rtc.h
@@ -76,5 +76,9 @@
#define RTC_PF 0x40
#define RTC_AF 0x20
#define RTC_UF 0x10
+#define RTC_FEATURE_ALARM 0
+#define RTC_FEATURE_ALARM_RES_MINUTE 1
+#define RTC_FEATURE_NEED_WEEK_DAY 2
+#define RTC_FEATURE_CNT 3
#define RTC_MAX_FREQ 8192
#endif
diff --git a/libc/kernel/uapi/linux/rtnetlink.h b/libc/kernel/uapi/linux/rtnetlink.h
index 335a5e9..22f8f1c 100644
--- a/libc/kernel/uapi/linux/rtnetlink.h
+++ b/libc/kernel/uapi/linux/rtnetlink.h
@@ -239,6 +239,7 @@
#define RTM_F_FIB_MATCH 0x2000
#define RTM_F_OFFLOAD 0x4000
#define RTM_F_TRAP 0x8000
+#define RTM_F_OFFLOAD_FAILED 0x20000000
enum rt_class_t {
RT_TABLE_UNSPEC = 0,
RT_TABLE_COMPAT = 252,
diff --git a/libc/kernel/uapi/linux/serial_core.h b/libc/kernel/uapi/linux/serial_core.h
index fd75fff..0caf698 100644
--- a/libc/kernel/uapi/linux/serial_core.h
+++ b/libc/kernel/uapi/linux/serial_core.h
@@ -100,7 +100,6 @@
#define PORT_VT8500 97
#define PORT_XUARTPS 98
#define PORT_AR933X 99
-#define PORT_EFMUART 100
#define PORT_ARC 101
#define PORT_RP2 102
#define PORT_LPUART 103
diff --git a/libc/kernel/uapi/linux/spi/spi.h b/libc/kernel/uapi/linux/spi/spi.h
new file mode 100644
index 0000000..39267a2
--- /dev/null
+++ b/libc/kernel/uapi/linux/spi/spi.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_SPI_H
+#define _UAPI_SPI_H
+#include <linux/const.h>
+#define SPI_CPHA _BITUL(0)
+#define SPI_CPOL _BITUL(1)
+#define SPI_MODE_0 (0 | 0)
+#define SPI_MODE_1 (0 | SPI_CPHA)
+#define SPI_MODE_2 (SPI_CPOL | 0)
+#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA)
+#define SPI_MODE_X_MASK (SPI_CPOL | SPI_CPHA)
+#define SPI_CS_HIGH _BITUL(2)
+#define SPI_LSB_FIRST _BITUL(3)
+#define SPI_3WIRE _BITUL(4)
+#define SPI_LOOP _BITUL(5)
+#define SPI_NO_CS _BITUL(6)
+#define SPI_READY _BITUL(7)
+#define SPI_TX_DUAL _BITUL(8)
+#define SPI_TX_QUAD _BITUL(9)
+#define SPI_RX_DUAL _BITUL(10)
+#define SPI_RX_QUAD _BITUL(11)
+#define SPI_CS_WORD _BITUL(12)
+#define SPI_TX_OCTAL _BITUL(13)
+#define SPI_RX_OCTAL _BITUL(14)
+#define SPI_3WIRE_HIZ _BITUL(15)
+#define SPI_MODE_USER_MASK (_BITUL(16) - 1)
+#endif
diff --git a/libc/kernel/uapi/linux/spi/spidev.h b/libc/kernel/uapi/linux/spi/spidev.h
index dede0f0..19d1d84 100644
--- a/libc/kernel/uapi/linux/spi/spidev.h
+++ b/libc/kernel/uapi/linux/spi/spidev.h
@@ -20,26 +20,7 @@
#define SPIDEV_H
#include <linux/types.h>
#include <linux/ioctl.h>
-#define SPI_CPHA 0x01
-#define SPI_CPOL 0x02
-#define SPI_MODE_0 (0 | 0)
-#define SPI_MODE_1 (0 | SPI_CPHA)
-#define SPI_MODE_2 (SPI_CPOL | 0)
-#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA)
-#define SPI_CS_HIGH 0x04
-#define SPI_LSB_FIRST 0x08
-#define SPI_3WIRE 0x10
-#define SPI_LOOP 0x20
-#define SPI_NO_CS 0x40
-#define SPI_READY 0x80
-#define SPI_TX_DUAL 0x100
-#define SPI_TX_QUAD 0x200
-#define SPI_RX_DUAL 0x400
-#define SPI_RX_QUAD 0x800
-#define SPI_CS_WORD 0x1000
-#define SPI_TX_OCTAL 0x2000
-#define SPI_RX_OCTAL 0x4000
-#define SPI_3WIRE_HIZ 0x8000
+#include <linux/spi/spi.h>
#define SPI_IOC_MAGIC 'k'
struct spi_ioc_transfer {
__u64 tx_buf;
diff --git a/libc/kernel/uapi/linux/surface_aggregator/cdev.h b/libc/kernel/uapi/linux/surface_aggregator/cdev.h
new file mode 100644
index 0000000..25bfd8d
--- /dev/null
+++ b/libc/kernel/uapi/linux/surface_aggregator/cdev.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H
+#define _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H
+#include <linux/ioctl.h>
+#include <linux/types.h>
+enum ssam_cdev_request_flags {
+ SSAM_CDEV_REQUEST_HAS_RESPONSE = 0x01,
+ SSAM_CDEV_REQUEST_UNSEQUENCED = 0x02,
+};
+struct ssam_cdev_request {
+ __u8 target_category;
+ __u8 target_id;
+ __u8 command_id;
+ __u8 instance_id;
+ __u16 flags;
+ __s16 status;
+ struct {
+ __u64 data;
+ __u16 length;
+ __u8 __pad[6];
+ } payload;
+ struct {
+ __u64 data;
+ __u16 length;
+ __u8 __pad[6];
+ } response;
+} __attribute__((__packed__));
+#define SSAM_CDEV_REQUEST _IOWR(0xA5, 1, struct ssam_cdev_request)
+#endif
diff --git a/libc/kernel/uapi/linux/sysctl.h b/libc/kernel/uapi/linux/sysctl.h
index 3f53f2d..ebaf8a9 100644
--- a/libc/kernel/uapi/linux/sysctl.h
+++ b/libc/kernel/uapi/linux/sysctl.h
@@ -489,6 +489,7 @@
NET_IPV6_ACCEPT_SOURCE_ROUTE = 25,
NET_IPV6_ACCEPT_RA_FROM_LOCAL = 26,
NET_IPV6_ACCEPT_RA_RT_INFO_MIN_PLEN = 27,
+ NET_IPV6_RA_DEFRTR_METRIC = 28,
__NET_IPV6_MAX
};
enum {
diff --git a/libc/kernel/uapi/linux/tcp.h b/libc/kernel/uapi/linux/tcp.h
index 2ca37a6..99c5bff 100644
--- a/libc/kernel/uapi/linux/tcp.h
+++ b/libc/kernel/uapi/linux/tcp.h
@@ -220,6 +220,7 @@
TCP_NLA_TIMEOUT_REHASH,
TCP_NLA_BYTES_NOTSENT,
TCP_NLA_EDT,
+ TCP_NLA_TTL,
};
#define TCP_MD5SIG_MAXKEYLEN 80
#define TCP_MD5SIG_FLAG_PREFIX 0x1
@@ -249,5 +250,9 @@
__u64 copybuf_address;
__s32 copybuf_len;
__u32 flags;
+ __u64 msg_control;
+ __u64 msg_controllen;
+ __u32 msg_flags;
+ __u32 reserved;
};
#endif
diff --git a/libc/kernel/uapi/linux/termios.h b/libc/kernel/uapi/linux/termios.h
index a665735..cde4099 100644
--- a/libc/kernel/uapi/linux/termios.h
+++ b/libc/kernel/uapi/linux/termios.h
@@ -20,15 +20,4 @@
#define _LINUX_TERMIOS_H
#include <linux/types.h>
#include <asm/termios.h>
-#define NFF 5
-struct termiox {
- __u16 x_hflag;
- __u16 x_cflag;
- __u16 x_rflag[NFF];
- __u16 x_sflag;
-};
-#define RTSXOFF 0x0001
-#define CTSXON 0x0002
-#define DTRXOFF 0x0004
-#define DSRXON 0x0008
#endif
diff --git a/libc/kernel/uapi/linux/usb/ch9.h b/libc/kernel/uapi/linux/usb/ch9.h
index 43d2f4b..f1dade9 100644
--- a/libc/kernel/uapi/linux/usb/ch9.h
+++ b/libc/kernel/uapi/linux/usb/ch9.h
@@ -434,9 +434,19 @@
__le32 bmSublinkSpeedAttr[1];
#define USB_SSP_SUBLINK_SPEED_SSID (0xf)
#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4)
+#define USB_SSP_SUBLINK_SPEED_LSE_BPS 0
+#define USB_SSP_SUBLINK_SPEED_LSE_KBPS 1
+#define USB_SSP_SUBLINK_SPEED_LSE_MBPS 2
+#define USB_SSP_SUBLINK_SPEED_LSE_GBPS 3
#define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6)
+#define USB_SSP_SUBLINK_SPEED_ST_SYM_RX 0
+#define USB_SSP_SUBLINK_SPEED_ST_ASYM_RX 1
+#define USB_SSP_SUBLINK_SPEED_ST_SYM_TX 2
+#define USB_SSP_SUBLINK_SPEED_ST_ASYM_TX 3
#define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8)
#define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14)
+#define USB_SSP_SUBLINK_SPEED_LP_SS 0
+#define USB_SSP_SUBLINK_SPEED_LP_SSP 1
#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16)
} __attribute__((packed));
#define USB_PD_POWER_DELIVERY_CAPABILITY 0x06
diff --git a/libc/kernel/uapi/linux/usb/tmc.h b/libc/kernel/uapi/linux/usb/tmc.h
index 20c061b..6d0add1 100644
--- a/libc/kernel/uapi/linux/usb/tmc.h
+++ b/libc/kernel/uapi/linux/usb/tmc.h
@@ -86,6 +86,8 @@
#define USBTMC488_IOCTL_WAIT_SRQ _IOW(USBTMC_IOC_NR, 23, __u32)
#define USBTMC_IOCTL_MSG_IN_ATTR _IOR(USBTMC_IOC_NR, 24, __u8)
#define USBTMC_IOCTL_AUTO_ABORT _IOW(USBTMC_IOC_NR, 25, __u8)
+#define USBTMC_IOCTL_GET_STB _IOR(USBTMC_IOC_NR, 26, __u8)
+#define USBTMC_IOCTL_GET_SRQ_STB _IOR(USBTMC_IOC_NR, 27, __u8)
#define USBTMC_IOCTL_CANCEL_IO _IO(USBTMC_IOC_NR, 35)
#define USBTMC_IOCTL_CLEANUP_IO _IO(USBTMC_IOC_NR, 36)
#define USBTMC488_CAPABILITY_TRIGGER 1
diff --git a/libc/kernel/uapi/linux/v4l2-controls.h b/libc/kernel/uapi/linux/v4l2-controls.h
index 4cb46e2..75e5ccd 100644
--- a/libc/kernel/uapi/linux/v4l2-controls.h
+++ b/libc/kernel/uapi/linux/v4l2-controls.h
@@ -113,6 +113,7 @@
#define V4L2_CID_USER_IMX_BASE (V4L2_CID_USER_BASE + 0x10b0)
#define V4L2_CID_USER_ATMEL_ISC_BASE (V4L2_CID_USER_BASE + 0x10c0)
#define V4L2_CID_USER_CODA_BASE (V4L2_CID_USER_BASE + 0x10e0)
+#define V4L2_CID_USER_CCS_BASE (V4L2_CID_USER_BASE + 0x10f0)
#define V4L2_CID_CODEC_BASE (V4L2_CTRL_CLASS_CODEC | 0x900)
#define V4L2_CID_CODEC_CLASS (V4L2_CTRL_CLASS_CODEC | 1)
#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_CODEC_BASE + 0)
@@ -316,6 +317,7 @@
#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_CODEC_BASE + 227)
#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_CODEC_BASE + 228)
#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (V4L2_CID_CODEC_BASE + 229)
+#define V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID (V4L2_CID_CODEC_BASE + 230)
#define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE + 270)
enum v4l2_mpeg_video_mpeg2_level {
V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW = 0,
@@ -474,6 +476,15 @@
#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP (V4L2_CID_CODEC_BASE + 386)
#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP (V4L2_CID_CODEC_BASE + 387)
#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP (V4L2_CID_CODEC_BASE + 388)
+#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (V4L2_CID_CODEC_BASE + 389)
+#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (V4L2_CID_CODEC_BASE + 390)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR (V4L2_CID_CODEC_BASE + 391)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR (V4L2_CID_CODEC_BASE + 392)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR (V4L2_CID_CODEC_BASE + 393)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR (V4L2_CID_CODEC_BASE + 394)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR (V4L2_CID_CODEC_BASE + 395)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR (V4L2_CID_CODEC_BASE + 396)
+#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR (V4L2_CID_CODEC_BASE + 397)
#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (V4L2_CID_CODEC_BASE + 400)
#define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (V4L2_CID_CODEC_BASE + 401)
#define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (V4L2_CID_CODEC_BASE + 402)
@@ -653,6 +664,12 @@
V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT = 1,
V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT = 2,
};
+#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP (V4L2_CID_CODEC_BASE + 647)
+#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP (V4L2_CID_CODEC_BASE + 648)
+#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP (V4L2_CID_CODEC_BASE + 649)
+#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP (V4L2_CID_CODEC_BASE + 650)
+#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP (V4L2_CID_CODEC_BASE + 651)
+#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP (V4L2_CID_CODEC_BASE + 652)
#define V4L2_CID_CODEC_CX2341X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000)
#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_CODEC_CX2341X_BASE + 0)
enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
diff --git a/libc/kernel/uapi/linux/vdpa.h b/libc/kernel/uapi/linux/vdpa.h
new file mode 100644
index 0000000..bee6618
--- /dev/null
+++ b/libc/kernel/uapi/linux/vdpa.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _UAPI_LINUX_VDPA_H_
+#define _UAPI_LINUX_VDPA_H_
+#define VDPA_GENL_NAME "vdpa"
+#define VDPA_GENL_VERSION 0x1
+enum vdpa_command {
+ VDPA_CMD_UNSPEC,
+ VDPA_CMD_MGMTDEV_NEW,
+ VDPA_CMD_MGMTDEV_GET,
+ VDPA_CMD_DEV_NEW,
+ VDPA_CMD_DEV_DEL,
+ VDPA_CMD_DEV_GET,
+};
+enum vdpa_attr {
+ VDPA_ATTR_UNSPEC,
+ VDPA_ATTR_MGMTDEV_BUS_NAME,
+ VDPA_ATTR_MGMTDEV_DEV_NAME,
+ VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES,
+ VDPA_ATTR_DEV_NAME,
+ VDPA_ATTR_DEV_ID,
+ VDPA_ATTR_DEV_VENDOR_ID,
+ VDPA_ATTR_DEV_MAX_VQS,
+ VDPA_ATTR_DEV_MAX_VQ_SIZE,
+ VDPA_ATTR_MAX,
+};
+#endif
diff --git a/libc/kernel/uapi/linux/version.h b/libc/kernel/uapi/linux/version.h
index e5c1243..86c0070 100644
--- a/libc/kernel/uapi/linux/version.h
+++ b/libc/kernel/uapi/linux/version.h
@@ -16,5 +16,8 @@
***
****************************************************************************
****************************************************************************/
-#define LINUX_VERSION_CODE 330496
-#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#define LINUX_VERSION_CODE 330752
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
+#define LINUX_VERSION_MAJOR 5
+#define LINUX_VERSION_PATCHLEVEL 12
+#define LINUX_VERSION_SUBLEVEL 0
diff --git a/libc/kernel/uapi/linux/vfio.h b/libc/kernel/uapi/linux/vfio.h
index f0f5c8f..e0f322b 100644
--- a/libc/kernel/uapi/linux/vfio.h
+++ b/libc/kernel/uapi/linux/vfio.h
@@ -29,6 +29,8 @@
#define VFIO_TYPE1_NESTING_IOMMU 6
#define VFIO_SPAPR_TCE_v2_IOMMU 7
#define VFIO_NOIOMMU_IOMMU 8
+#define VFIO_UNMAP_ALL 9
+#define VFIO_UPDATE_VADDR 10
#define VFIO_TYPE (';')
#define VFIO_BASE 100
struct vfio_info_cap_header {
@@ -320,6 +322,7 @@
__u32 flags;
#define VFIO_DMA_MAP_FLAG_READ (1 << 0)
#define VFIO_DMA_MAP_FLAG_WRITE (1 << 1)
+#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2)
__u64 vaddr;
__u64 iova;
__u64 size;
@@ -334,6 +337,8 @@
__u32 argsz;
__u32 flags;
#define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0)
+#define VFIO_DMA_UNMAP_FLAG_ALL (1 << 1)
+#define VFIO_DMA_UNMAP_FLAG_VADDR (1 << 2)
__u64 iova;
__u64 size;
__u8 data[];
diff --git a/libc/kernel/uapi/misc/habanalabs.h b/libc/kernel/uapi/misc/habanalabs.h
index d8f724b..b009023 100644
--- a/libc/kernel/uapi/misc/habanalabs.h
+++ b/libc/kernel/uapi/misc/habanalabs.h
@@ -240,7 +240,9 @@
__u32 num_of_events;
__u32 device_id;
__u32 module_id;
- __u32 reserved[2];
+ __u32 reserved;
+ __u16 first_available_interrupt_id;
+ __u16 reserved2;
__u32 cpld_version;
__u32 psoc_pci_pll_nr;
__u32 psoc_pci_pll_nf;
@@ -251,15 +253,18 @@
__u8 pad[2];
__u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
__u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
+ __u64 reserved3;
+ __u64 dram_page_size;
};
struct hl_info_dram_usage {
__u64 dram_free_mem;
__u64 ctx_dram_mem;
};
+#define HL_BUSY_ENGINES_MASK_EXT_SIZE 2
struct hl_info_hw_idle {
__u32 is_idle;
__u32 busy_engines_mask;
- __u64 busy_engines_mask_ext;
+ __u64 busy_engines_mask_ext[HL_BUSY_ENGINES_MASK_EXT_SIZE];
};
struct hl_info_device_status {
__u32 status;
@@ -301,6 +306,8 @@
struct hl_info_sync_manager {
__u32 first_available_sync_object;
__u32 first_available_monitor;
+ __u32 first_available_cq;
+ __u32 reserved;
};
struct hl_info_cs_counters {
__u64 total_out_of_mem_drop_cnt;
@@ -379,12 +386,18 @@
#define HL_CS_FLAGS_WAIT 0x4
#define HL_CS_FLAGS_COLLECTIVE_WAIT 0x8
#define HL_CS_FLAGS_TIMESTAMP 0x20
+#define HL_CS_FLAGS_STAGED_SUBMISSION 0x40
+#define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x80
+#define HL_CS_FLAGS_STAGED_SUBMISSION_LAST 0x100
#define HL_CS_STATUS_SUCCESS 0
#define HL_MAX_JOBS_PER_CS 512
struct hl_cs_in {
__u64 chunks_restore;
__u64 chunks_execute;
- __u64 chunks_store;
+ union {
+ __u64 chunks_store;
+ __u64 seq;
+ };
__u32 num_chunks_restore;
__u32 num_chunks_execute;
__u32 num_chunks_store;
@@ -426,6 +439,7 @@
#define HL_MEM_OP_FREE 1
#define HL_MEM_OP_MAP 2
#define HL_MEM_OP_UNMAP 3
+#define HL_MEM_OP_MAP_BLOCK 4
#define HL_MEM_CONTIGUOUS 0x1
#define HL_MEM_SHARED 0x2
#define HL_MEM_USERPTR 0x4
@@ -447,6 +461,9 @@
__u64 mem_size;
} map_host;
struct {
+ __u64 block_addr;
+ } map_block;
+ struct {
__u64 device_virt_addr;
} unmap;
};
@@ -459,6 +476,11 @@
union {
__u64 device_virt_addr;
__u64 handle;
+ struct {
+ __u64 block_handle;
+ __u32 block_size;
+ __u32 pad;
+ };
};
};
union hl_mem_args {
diff --git a/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h b/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h
index 15af02e..f96b4e8 100644
--- a/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h
+++ b/libc/kernel/uapi/rdma/ib_user_ioctl_cmds.h
@@ -206,6 +206,7 @@
UVERBS_METHOD_MR_DESTROY,
UVERBS_METHOD_ADVISE_MR,
UVERBS_METHOD_QUERY_MR,
+ UVERBS_METHOD_REG_DMABUF_MR,
};
enum uverbs_attrs_mr_destroy_ids {
UVERBS_ATTR_DESTROY_MR_HANDLE,
@@ -223,6 +224,17 @@
UVERBS_ATTR_QUERY_MR_RESP_LENGTH,
UVERBS_ATTR_QUERY_MR_RESP_IOVA,
};
+enum uverbs_attrs_reg_dmabuf_mr_cmd_attr_ids {
+ UVERBS_ATTR_REG_DMABUF_MR_HANDLE,
+ UVERBS_ATTR_REG_DMABUF_MR_PD_HANDLE,
+ UVERBS_ATTR_REG_DMABUF_MR_OFFSET,
+ UVERBS_ATTR_REG_DMABUF_MR_LENGTH,
+ UVERBS_ATTR_REG_DMABUF_MR_IOVA,
+ UVERBS_ATTR_REG_DMABUF_MR_FD,
+ UVERBS_ATTR_REG_DMABUF_MR_ACCESS_FLAGS,
+ UVERBS_ATTR_REG_DMABUF_MR_RESP_LKEY,
+ UVERBS_ATTR_REG_DMABUF_MR_RESP_RKEY,
+};
enum uverbs_attrs_create_counters_cmd_attr_ids {
UVERBS_ATTR_CREATE_COUNTERS_HANDLE,
};
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 51a1076..c31e306 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1772,6 +1772,7 @@
android_fdtrack_compare_exchange_hook; # llndk
android_fdtrack_get_enabled; # llndk
android_fdtrack_set_enabled; # llndk
+ android_fdtrack_set_globally_enabled; # llndk
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp
index 4f81ff7..90c9136 100644
--- a/libc/malloc_debug/PointerData.cpp
+++ b/libc/malloc_debug/PointerData.cpp
@@ -588,8 +588,8 @@
dprintf(fd, " bt_info");
for (const auto& frame : *info.backtrace_info) {
dprintf(fd, " {");
- if (frame.map_info != nullptr && !frame.map_info->name.empty()) {
- dprintf(fd, "\"%s\"", frame.map_info->name.c_str());
+ if (frame.map_info != nullptr && !frame.map_info->name().empty()) {
+ dprintf(fd, "\"%s\"", frame.map_info->name().c_str());
} else {
dprintf(fd, "\"\"");
}
diff --git a/libc/malloc_debug/UnwindBacktrace.cpp b/libc/malloc_debug/UnwindBacktrace.cpp
index 92fb3fa..128991b 100644
--- a/libc/malloc_debug/UnwindBacktrace.cpp
+++ b/libc/malloc_debug/UnwindBacktrace.cpp
@@ -90,14 +90,14 @@
unwindstack::MapInfo* map_info = info->map_info;
std::string line = android::base::StringPrintf(" #%0zd pc %" PAD_PTR " ", i, info->rel_pc);
- if (map_info->offset != 0) {
- line += android::base::StringPrintf("(offset 0x%" PRIx64 ") ", map_info->offset);
+ if (map_info->offset() != 0) {
+ line += android::base::StringPrintf("(offset 0x%" PRIx64 ") ", map_info->offset());
}
- if (map_info->name.empty()) {
- line += android::base::StringPrintf("<anonymous:%" PRIx64 ">", map_info->start);
+ if (map_info->name().empty()) {
+ line += android::base::StringPrintf("<anonymous:%" PRIx64 ">", map_info->start());
} else {
- line += map_info->name;
+ line += map_info->name();
}
if (!info->function_name.empty()) {
diff --git a/libc/platform/bionic/fdtrack.h b/libc/platform/bionic/fdtrack.h
index 6eb379b..fe6ca84 100644
--- a/libc/platform/bionic/fdtrack.h
+++ b/libc/platform/bionic/fdtrack.h
@@ -70,4 +70,8 @@
bool android_fdtrack_get_enabled() __INTRODUCED_IN(30);
bool android_fdtrack_set_enabled(bool new_value) __INTRODUCED_IN(30);
+// Globally enable/disable fdtrack.
+// This is primaryily useful to reenable fdtrack after it's been automatically disabled post-fork.
+void android_fdtrack_set_globally_enabled(bool new_value) __INTRODUCED_IN(31);
+
__END_DECLS
diff --git a/libc/private/bionic_fdtrack.h b/libc/private/bionic_fdtrack.h
index 259897c..c05b32b 100644
--- a/libc/private/bionic_fdtrack.h
+++ b/libc/private/bionic_fdtrack.h
@@ -28,41 +28,43 @@
#pragma once
-#include <sys/cdefs.h>
#include <stdatomic.h>
+#include <sys/cdefs.h>
#include "platform/bionic/fdtrack.h"
#include "bionic/pthread_internal.h"
-#include "private/bionic_tls.h"
#include "private/ErrnoRestorer.h"
+#include "private/bionic_tls.h"
extern "C" _Atomic(android_fdtrack_hook_t) __android_fdtrack_hook;
+extern "C" bool __android_fdtrack_globally_disabled;
// Macro to record file descriptor creation.
// e.g.:
// int socket(int domain, int type, int protocol) {
// return FDTRACK_CREATE_NAME("socket", __socket(domain, type, protocol));
// }
-#define FDTRACK_CREATE_NAME(name, fd_value) \
- ({ \
- int __fd = (fd_value); \
- if (__fd != -1 && __predict_false(__android_fdtrack_hook) && \
- !__predict_false(__get_thread()->is_vforked())) { \
- bionic_tls& tls = __get_bionic_tls(); \
- /* fdtrack_disabled is only true during reentrant calls. */ \
- if (!__predict_false(tls.fdtrack_disabled)) { \
- ErrnoRestorer r; \
- tls.fdtrack_disabled = true; \
- android_fdtrack_event event; \
- event.fd = __fd; \
- event.type = ANDROID_FDTRACK_EVENT_TYPE_CREATE; \
- event.data.create.function_name = name; \
- atomic_load(&__android_fdtrack_hook)(&event); \
- tls.fdtrack_disabled = false; \
- } \
- } \
- __fd; \
+#define FDTRACK_CREATE_NAME(name, fd_value) \
+ ({ \
+ int __fd = (fd_value); \
+ if (__fd != -1 && __predict_false(__android_fdtrack_hook) && \
+ !__predict_false(__get_thread()->is_vforked())) { \
+ bionic_tls& tls = __get_bionic_tls(); \
+ /* fdtrack_disabled is only true during reentrant calls. */ \
+ if (!__predict_false(tls.fdtrack_disabled) && \
+ !__predict_false(__android_fdtrack_globally_disabled)) { \
+ ErrnoRestorer r; \
+ tls.fdtrack_disabled = true; \
+ android_fdtrack_event event; \
+ event.fd = __fd; \
+ event.type = ANDROID_FDTRACK_EVENT_TYPE_CREATE; \
+ event.data.create.function_name = name; \
+ atomic_load (&__android_fdtrack_hook)(&event); \
+ tls.fdtrack_disabled = false; \
+ } \
+ } \
+ __fd; \
})
// Macro to record file descriptor creation, with the current function's name.
@@ -74,22 +76,23 @@
// Macro to record file descriptor closure.
// Note that this does not actually close the file descriptor.
-#define FDTRACK_CLOSE(fd_value) \
- ({ \
- int __fd = (fd_value); \
- if (__fd != -1 && __predict_false(__android_fdtrack_hook) && \
- !__predict_false(__get_thread()->is_vforked())) { \
- bionic_tls& tls = __get_bionic_tls(); \
- if (!__predict_false(tls.fdtrack_disabled)) { \
- int saved_errno = errno; \
- tls.fdtrack_disabled = true; \
- android_fdtrack_event event; \
- event.fd = __fd; \
- event.type = ANDROID_FDTRACK_EVENT_TYPE_CLOSE; \
- atomic_load(&__android_fdtrack_hook)(&event); \
- tls.fdtrack_disabled = false; \
- errno = saved_errno; \
- } \
- } \
- __fd; \
+#define FDTRACK_CLOSE(fd_value) \
+ ({ \
+ int __fd = (fd_value); \
+ if (__fd != -1 && __predict_false(__android_fdtrack_hook) && \
+ !__predict_false(__get_thread()->is_vforked())) { \
+ bionic_tls& tls = __get_bionic_tls(); \
+ if (!__predict_false(tls.fdtrack_disabled) && \
+ !__predict_false(__android_fdtrack_globally_disabled)) { \
+ int saved_errno = errno; \
+ tls.fdtrack_disabled = true; \
+ android_fdtrack_event event; \
+ event.fd = __fd; \
+ event.type = ANDROID_FDTRACK_EVENT_TYPE_CLOSE; \
+ atomic_load (&__android_fdtrack_hook)(&event); \
+ tls.fdtrack_disabled = false; \
+ errno = saved_errno; \
+ } \
+ } \
+ __fd; \
})
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
index 3fd20b7..344c838 100644
--- a/libc/system_properties/system_properties.cpp
+++ b/libc/system_properties/system_properties.cpp
@@ -133,7 +133,7 @@
prop_area* pa = contexts_->GetPropAreaForName(name);
if (!pa) {
- async_safe_format_log(ANDROID_LOG_ERROR, "libc", "Access denied finding property \"%s\"", name);
+ async_safe_format_log(ANDROID_LOG_WARN, "libc", "Access denied finding property \"%s\"", name);
return nullptr;
}
diff --git a/libc/tools/check-symbols-glibc.py b/libc/tools/check-symbols-glibc.py
index d8d1982..613aa88 100755
--- a/libc/tools/check-symbols-glibc.py
+++ b/libc/tools/check-symbols-glibc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# Copyright (C) 2015 The Android Open Source Project
#
@@ -231,33 +231,33 @@
glibc = glibc - in_posix_and_glibc_but_dead_or_useless
if not only_unwanted:
- #print 'glibc:'
+ #print('glibc:')
#for symbol in sorted(glibc):
- # print symbol
- #print
+ # print(symbol)
+ #print()
- #print 'bionic:'
+ #print('bionic:')
#for symbol in sorted(bionic):
- # print symbol
- #print
+ # print(symbol)
+ #print()
- print 'in glibc (but not posix) but not bionic:'
+ print('in glibc (but not posix) but not bionic:')
for symbol in sorted((glibc - posix).difference(bionic)):
- print symbol
- print
+ print(symbol)
+ print()
- print 'in posix (and implemented in glibc) but not bionic:'
+ print('in posix (and implemented in glibc) but not bionic:')
for symbol in sorted((posix.intersection(glibc)).difference(bionic)):
- print symbol
- print
+ print(symbol)
+ print()
- print 'in bionic but not glibc:'
+ print('in bionic but not glibc:')
allowed_stuff = (bsd_stuff | FORTIFY_stuff | linux_stuff | macro_stuff |
std_stuff | weird_stuff | libresolv_stuff | known)
for symbol in sorted((bionic - allowed_stuff).difference(glibc)):
if symbol in ndk_ignored:
symbol += '*'
- print symbol
+ print(symbol)
sys.exit(0)
diff --git a/libc/tools/check-symbols.py b/libc/tools/check-symbols.py
deleted file mode 100755
index 6568917..0000000
--- a/libc/tools/check-symbols.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python
-
-import glob
-import os
-import re
-import string
-import subprocess
-import sys
-
-toolchain = os.environ['ANDROID_TOOLCHAIN']
-arch = re.sub(r'.*/linux-x86/([^/]+)/.*', r'\1', toolchain)
-
-sys.stderr.write('Checking symbols for arch "%s"...\n' % arch)
-
-def GetSymbols(library, functions_or_variables):
- global api
- global arch
-
- api = '9'
- if library == 'libm' and arch == 'arm':
- api = '3'
-
- # There were no 64-bit ABIs before API level 21.
- if '64' in arch:
- api = '21'
-
- # What GCC calls aarch64, Android calls arm64.
- if arch == 'aarch64':
- arch = 'arm64'
-
- path = '%s/development/ndk/platforms/android-%s/arch-%s/symbols/%s.so.%s.txt' % (os.environ['ANDROID_BUILD_TOP'], api, arch, library, functions_or_variables)
- symbols = set()
- for line in open(path, 'r'):
- symbols.add(line.rstrip())
- #sys.stdout.write('%d %s in %s for %s\n' % (len(symbols), functions_or_variables, library, arch))
- return symbols
-
-def CheckSymbols(library, functions_or_variables):
- expected_symbols = GetSymbols(library, functions_or_variables)
-
- lib_dir = 'lib'
- if '64' in arch:
- lib_dir = 'lib64'
-
- so_file = '%s/system/%s/%s.so' % (os.environ['ANDROID_PRODUCT_OUT'], lib_dir, library)
-
- # Example readelf output:
- # 264: 0001623c 4 FUNC GLOBAL DEFAULT 8 cabsf
- # 266: 00016244 4 FUNC GLOBAL DEFAULT 8 dremf
- # 267: 00019018 4 OBJECT GLOBAL DEFAULT 11 __fe_dfl_env
- # 268: 00000000 0 FUNC GLOBAL DEFAULT UND __aeabi_dcmplt
-
-
- r = re.compile(r' +\d+: [0-9a-f]+ +\d+ (FUNC|OBJECT) +\S+ +\S+ +\d+ (\S+)')
-
- actual_symbols = set()
- for line in subprocess.check_output(['readelf', '-W', '--dyn-syms', so_file]).split('\n'):
- m = r.match(line)
- if m:
- symbol = string.split(m.group(2), '@')[0]
- if m.group(1) == 'FUNC' and functions_or_variables == 'functions':
- actual_symbols.add(symbol)
- elif m.group(1) == 'OBJECT' and functions_or_variables == 'variables':
- actual_symbols.add(symbol)
- #else:
- #print 'ignoring: ' % line
-
- missing = expected_symbols - actual_symbols
- if len(missing) > 0:
- sys.stderr.write('%d missing %s in %s for %s:\n' % (len(missing), functions_or_variables, library, arch))
- for miss in sorted(missing):
- sys.stderr.write(' %s\n' % miss)
-
- extra = actual_symbols - expected_symbols
- if len(extra) > 0:
- sys.stderr.write('%d extra %s in %s for %s:\n' % (len(extra), functions_or_variables, library, arch))
- for s in sorted(extra):
- sys.stderr.write(' %s\n' % s)
-
- return len(missing) == 0
-
-CheckSymbols("libc", "functions")
-CheckSymbols("libc", "variables")
-CheckSymbols("libm", "functions")
-CheckSymbols("libm", "variables")
-
-sys.exit(0)
diff --git a/libc/tools/generate_notice.py b/libc/tools/generate_notice.py
index e0e6b32..e004d74 100755
--- a/libc/tools/generate_notice.py
+++ b/libc/tools/generate_notice.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Run with directory arguments from any directory, with no special setup
# required.
@@ -38,6 +38,9 @@
return False
if path.name in {"notice", "readme", "pylintrc"}:
return False
+ # Backup files for some editors.
+ if path.match("*~"):
+ return False
return True
diff --git a/libc/tools/genfunctosyscallnrs.py b/libc/tools/genfunctosyscallnrs.py
index 26642f9..fa48844 100755
--- a/libc/tools/genfunctosyscallnrs.py
+++ b/libc/tools/genfunctosyscallnrs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import argparse
import logging
diff --git a/libc/tools/genseccomp.py b/libc/tools/genseccomp.py
index a78f6c1..33bf470 100755
--- a/libc/tools/genseccomp.py
+++ b/libc/tools/genseccomp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import argparse
import logging
diff --git a/libc/tools/genserv.py b/libc/tools/genserv.py
index 84a139d..acbfea2 100755
--- a/libc/tools/genserv.py
+++ b/libc/tools/genserv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
import sys, os, string, re
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index d8d4302..baaa52d 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# This tool is used to generate the assembler system call stubs,
# the header files listing all available system calls, and the
@@ -434,13 +434,13 @@
for syscall in parser.syscalls:
syscall["__NR_name"] = make__NR_name(syscall["name"])
- if syscall.has_key("arm"):
+ if "arm" in syscall:
syscall["asm-arm"] = add_footer(32, arm_eabi_genstub(syscall), syscall)
- if syscall.has_key("arm64"):
+ if "arm64" in syscall:
syscall["asm-arm64"] = add_footer(64, arm64_genstub(syscall), syscall)
- if syscall.has_key("x86"):
+ if "x86" in syscall:
if syscall["socketcall_id"] >= 0:
syscall["asm-x86"] = add_footer(32, x86_genstub_socketcall(syscall), syscall)
else:
@@ -449,13 +449,13 @@
E("socketcall_id for dispatch syscalls is only supported for x86 in '%s'" % t)
return
- if syscall.has_key("x86_64"):
+ if "x86_64" in syscall:
syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
print("/* Generated by gensyscalls.py. Do not edit. */\n")
print("#include <private/bionic_asm.h>\n")
for syscall in parser.syscalls:
- if syscall.has_key("asm-%s" % arch):
+ if ("asm-%s" % arch) in syscall:
print(syscall["asm-%s" % arch])
if arch == 'arm64':
diff --git a/libc/tools/ndk_missing_symbols.py b/libc/tools/ndk_missing_symbols.py
index a9f92b1..eff6972 100755
--- a/libc/tools/ndk_missing_symbols.py
+++ b/libc/tools/ndk_missing_symbols.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# Copyright (C) 2015 The Android Open Source Project
#
diff --git a/libc/tools/symbols.py b/libc/tools/symbols.py
index 3f40aad..1457534 100644
--- a/libc/tools/symbols.py
+++ b/libc/tools/symbols.py
@@ -41,7 +41,8 @@
symbols = set()
- output = subprocess.check_output(['readelf', sym_type, '-W', elf_file])
+ output = subprocess.check_output(['readelf', sym_type, '-W', elf_file],
+ text=True)
for line in output.split('\n'):
if ' HIDDEN ' in line or ' UND ' in line:
continue
@@ -76,6 +77,10 @@
if not os.path.isdir(lib_dir):
lib_dir = os.path.join(out_dir, 'system/lib')
+ lib_dir = os.path.join(out_dir, 'apex/com.android.runtime/lib64/bionic/')
+ if not os.path.isdir(lib_dir):
+ lib_dir = os.path.join(out_dir, 'apex/com.android.runtime/lib/bionic/')
+
results = set()
for f in files:
results |= GetFromElf(os.path.join(lib_dir, f))
diff --git a/libc/tools/test_genseccomp.py b/libc/tools/test_genseccomp.py
index 8bd3517..b833c27 100755
--- a/libc/tools/test_genseccomp.py
+++ b/libc/tools/test_genseccomp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Unit tests for genseccomp.py
import textwrap
diff --git a/libc/upstream-netbsd/android/include/netbsd-compat.h b/libc/upstream-netbsd/android/include/netbsd-compat.h
index ea630b2..5dd086e 100644
--- a/libc/upstream-netbsd/android/include/netbsd-compat.h
+++ b/libc/upstream-netbsd/android/include/netbsd-compat.h
@@ -17,7 +17,7 @@
#pragma once
#define _BSD_SOURCE
-#define _GNU_SOURCE
+#define _GNU_SOURCE 1
// NetBSD uses _DIAGASSERT to null-check arguments and the like,
// but it's clear from the number of mistakes in their assertions
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 3004671..750a6e2 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -56,7 +56,6 @@
recovery_available: true,
native_bridge_supported: true,
static_ndk_lib: true,
- llndk_stubs: "libdl.llndk",
defaults: ["linux_bionic_supported"],
@@ -137,6 +136,9 @@
"current",
],
},
+ llndk: {
+ symbol_file: "libdl.map.txt",
+ },
apex_available: [
"//apex_available:platform",
@@ -235,12 +237,6 @@
first_version: "9",
}
-llndk_library {
- name: "libdl.llndk",
- native_bridge_supported: true,
- symbol_file: "libdl.map.txt",
-}
-
genrule {
name: "libdl.arm.map",
out: ["libdl.arm.map"],
diff --git a/libfdtrack/fdtrack.cpp b/libfdtrack/fdtrack.cpp
index fd56274..2e9cfbc 100644
--- a/libfdtrack/fdtrack.cpp
+++ b/libfdtrack/fdtrack.cpp
@@ -93,6 +93,8 @@
android_fdtrack_hook_t expected = nullptr;
installed = android_fdtrack_compare_exchange_hook(&expected, &fd_hook);
}
+
+ android_fdtrack_set_globally_enabled(true);
}
__attribute__((destructor)) static void dtor() {
diff --git a/libm/Android.bp b/libm/Android.bp
index 10f794a..6c3abd1 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -26,7 +26,6 @@
vendor_ramdisk_available: true,
recovery_available: true,
static_ndk_lib: true,
- llndk_stubs: "libm.llndk",
whole_static_libs: ["libarm-optimized-routines-math"],
@@ -528,6 +527,10 @@
],
},
+ llndk: {
+ symbol_file: "libm.map.txt",
+ },
+
apex_available: [
"//apex_available:platform",
"com.android.runtime",
@@ -544,12 +547,6 @@
first_version: "9",
}
-llndk_library {
- name: "libm.llndk",
- native_bridge_supported: true,
- symbol_file: "libm.map.txt",
-}
-
genrule {
name: "libm.arm.map",
out: ["libm.arm.map"],
diff --git a/linker/Android.bp b/linker/Android.bp
index 3370f28..4a5bf44 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -193,6 +193,7 @@
"linker_relocate.cpp",
"linker_sdk_versions.cpp",
"linker_soinfo.cpp",
+ "linker_transparent_hugepage_support.cpp",
"linker_tls.cpp",
"linker_utils.cpp",
"rt.cpp",
@@ -413,6 +414,19 @@
bazel_module: { bp2build_available: true },
}
+// Used to generate binaries that can be backed by transparent hugepages.
+cc_defaults {
+ name: "linker_hugepage_aligned",
+ arch: {
+ arm64: {
+ ldflags: ["-z max-page-size=0x200000"],
+ },
+ x86_64: {
+ ldflags: ["-z max-page-size=0x200000"],
+ },
+ },
+}
+
cc_library {
// NOTE: --exclude-libs=libgcc.a makes sure that any symbols ld-android.so pulls from
// libgcc.a are made static to ld-android.so. This in turn ensures that libraries that
diff --git a/linker/NOTICE b/linker/NOTICE
index 4cada69..8f70d87 100644
--- a/linker/NOTICE
+++ b/linker/NOTICE
@@ -306,3 +306,31 @@
-------------------------------------------------------------------
+Copyright (C) 2021 The Android Open Source Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
diff --git a/linker/linker.h b/linker/linker.h
index e1775fb..74bdcc7 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -110,6 +110,8 @@
void set_application_target_sdk_version(int target);
int get_application_target_sdk_version();
+bool get_transparent_hugepages_supported();
+
enum {
/* A regular namespace is the namespace with a custom search path that does
* not impose any restrictions on the location of native libraries.
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 0b501a7..2a690e9 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -31,9 +31,10 @@
#include <link.h>
#include <sys/auxv.h>
+#include "linker.h"
+#include "linker_cfi.h"
#include "linker_debug.h"
#include "linker_debuggerd.h"
-#include "linker_cfi.h"
#include "linker_gdb_support.h"
#include "linker_globals.h"
#include "linker_phdr.h"
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 9b1b99f..60fd776 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -70,8 +70,9 @@
p_memsz -> segment memory size (always >= p_filesz)
p_vaddr -> segment's virtual address
p_flags -> segment flags (e.g. readable, writable, executable)
+ p_align -> segment's in-memory and in-file alignment
- We will ignore the p_paddr and p_align fields of ElfW(Phdr) for now.
+ We will ignore the p_paddr field of ElfW(Phdr) for now.
The loadable segments can be seen as a list of [p_vaddr ... p_vaddr+p_memsz)
ranges of virtual addresses. A few rules apply:
@@ -137,6 +138,9 @@
MAYBE_MAP_FLAG((x), PF_R, PROT_READ) | \
MAYBE_MAP_FLAG((x), PF_W, PROT_WRITE))
+// Default PMD size for x86_64 and aarch64 (2MB).
+static constexpr size_t kPmdSize = (1UL << 21);
+
ElfReader::ElfReader()
: did_read_(false), did_load_(false), fd_(-1), file_offset_(0), file_size_(0), phdr_num_(0),
phdr_table_(nullptr), shdr_table_(nullptr), shdr_num_(0), dynamic_(nullptr), strtab_(nullptr),
@@ -526,12 +530,40 @@
return max_vaddr - min_vaddr;
}
+// Returns the maximum p_align associated with a loadable segment in the ELF
+// program header table. Used to determine whether the file should be loaded at
+// a specific virtual address alignment for use with huge pages.
+size_t phdr_table_get_maximum_alignment(const ElfW(Phdr)* phdr_table, size_t phdr_count) {
+ size_t maximum_alignment = PAGE_SIZE;
+
+ for (size_t i = 0; i < phdr_count; ++i) {
+ const ElfW(Phdr)* phdr = &phdr_table[i];
+
+ // p_align must be 0, 1, or a positive, integral power of two.
+ if (phdr->p_type != PT_LOAD || ((phdr->p_align & (phdr->p_align - 1)) != 0)) {
+ continue;
+ }
+
+ if (phdr->p_align > maximum_alignment) {
+ maximum_alignment = phdr->p_align;
+ }
+ }
+
+#if defined(__LP64__)
+ return maximum_alignment;
+#else
+ return PAGE_SIZE;
+#endif
+}
+
// Reserve a virtual address range such that if it's limits were extended to the next 2**align
// boundary, it would not overlap with any existing mappings.
-static void* ReserveWithAlignmentPadding(size_t size, size_t align, void** out_gap_start,
- size_t* out_gap_size) {
+static void* ReserveWithAlignmentPadding(size_t size, size_t mapping_align, size_t start_align,
+ void** out_gap_start, size_t* out_gap_size) {
int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
- if (align == PAGE_SIZE) {
+ // Reserve enough space to properly align the library's start address.
+ mapping_align = std::max(mapping_align, start_align);
+ if (mapping_align == PAGE_SIZE) {
void* mmap_ptr = mmap(nullptr, size, PROT_NONE, mmap_flags, -1, 0);
if (mmap_ptr == MAP_FAILED) {
return nullptr;
@@ -550,24 +582,24 @@
constexpr size_t kMaxGapUnits = 32;
// Allocate enough space so that the end of the desired region aligned up is still inside the
// mapping.
- size_t mmap_size = align_up(size, align) + align - PAGE_SIZE;
+ size_t mmap_size = align_up(size, mapping_align) + mapping_align - PAGE_SIZE;
uint8_t* mmap_ptr =
reinterpret_cast<uint8_t*>(mmap(nullptr, mmap_size, PROT_NONE, mmap_flags, -1, 0));
if (mmap_ptr == MAP_FAILED) {
return nullptr;
}
size_t gap_size = 0;
- size_t first_byte = reinterpret_cast<size_t>(align_up(mmap_ptr, align));
- size_t last_byte = reinterpret_cast<size_t>(align_down(mmap_ptr + mmap_size, align) - 1);
+ size_t first_byte = reinterpret_cast<size_t>(align_up(mmap_ptr, mapping_align));
+ size_t last_byte = reinterpret_cast<size_t>(align_down(mmap_ptr + mmap_size, mapping_align) - 1);
if (kGapAlignment && first_byte / kGapAlignment != last_byte / kGapAlignment) {
// This library crosses a 2MB boundary and will fragment a new huge page.
// Lets take advantage of that and insert a random number of inaccessible huge pages before that
// to improve address randomization and make it harder to locate this library code by probing.
munmap(mmap_ptr, mmap_size);
- align = std::max(align, kGapAlignment);
+ mapping_align = std::max(mapping_align, kGapAlignment);
gap_size =
kGapAlignment * (is_first_stage_init() ? 1 : arc4random_uniform(kMaxGapUnits - 1) + 1);
- mmap_size = align_up(size + gap_size, align) + align - PAGE_SIZE;
+ mmap_size = align_up(size + gap_size, mapping_align) + mapping_align - PAGE_SIZE;
mmap_ptr = reinterpret_cast<uint8_t*>(mmap(nullptr, mmap_size, PROT_NONE, mmap_flags, -1, 0));
if (mmap_ptr == MAP_FAILED) {
return nullptr;
@@ -582,13 +614,13 @@
gap_start = gap_end = mmap_ptr + mmap_size;
}
- uint8_t* first = align_up(mmap_ptr, align);
- uint8_t* last = align_down(gap_start, align) - size;
+ uint8_t* first = align_up(mmap_ptr, mapping_align);
+ uint8_t* last = align_down(gap_start, mapping_align) - size;
// arc4random* is not available in first stage init because /dev/urandom hasn't yet been
// created. Don't randomize then.
- size_t n = is_first_stage_init() ? 0 : arc4random_uniform((last - first) / PAGE_SIZE + 1);
- uint8_t* start = first + n * PAGE_SIZE;
+ size_t n = is_first_stage_init() ? 0 : arc4random_uniform((last - first) / start_align + 1);
+ uint8_t* start = first + n * start_align;
// Unmap the extra space around the allocation.
// Keep it mapped PROT_NONE on 64-bit targets where address space is plentiful to make it harder
// to defeat ASLR by probing for readable memory mappings.
@@ -622,7 +654,15 @@
load_size_ - address_space->reserved_size, load_size_, name_.c_str());
return false;
}
- start = ReserveWithAlignmentPadding(load_size_, kLibraryAlignment, &gap_start_, &gap_size_);
+ size_t start_alignment = PAGE_SIZE;
+ if (get_transparent_hugepages_supported() && get_application_target_sdk_version() >= 31) {
+ size_t maximum_alignment = phdr_table_get_maximum_alignment(phdr_table_, phdr_num_);
+ // Limit alignment to PMD size as other alignments reduce the number of
+ // bits available for ASLR for no benefit.
+ start_alignment = maximum_alignment == kPmdSize ? kPmdSize : PAGE_SIZE;
+ }
+ start = ReserveWithAlignmentPadding(load_size_, kLibraryAlignment, start_alignment, &gap_start_,
+ &gap_size_);
if (start == nullptr) {
DL_ERR("couldn't reserve %zd bytes of address space for \"%s\"", load_size_, name_.c_str());
return false;
@@ -706,6 +746,13 @@
DL_ERR("couldn't map \"%s\" segment %zd: %s", name_.c_str(), i, strerror(errno));
return false;
}
+
+ // Mark segments as huge page eligible if they meet the requirements
+ // (executable and PMD aligned).
+ if ((phdr->p_flags & PF_X) && phdr->p_align == kPmdSize &&
+ get_transparent_hugepages_supported()) {
+ madvise(seg_addr, file_length, MADV_HUGEPAGE);
+ }
}
// if the segment is writable, and does not end on a page boundary,
diff --git a/linker/linker_phdr.h b/linker/linker_phdr.h
index 548dc51..98bf020 100644
--- a/linker/linker_phdr.h
+++ b/linker/linker_phdr.h
@@ -120,6 +120,8 @@
size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count,
ElfW(Addr)* min_vaddr = nullptr, ElfW(Addr)* max_vaddr = nullptr);
+size_t phdr_table_get_maximum_alignment(const ElfW(Phdr)* phdr_table, size_t phdr_count);
+
int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count,
ElfW(Addr) load_bias, const GnuPropertySection* prop = nullptr);
diff --git a/libc/bionic/bionic_appcompat.h b/linker/linker_transparent_hugepage_support.cpp
similarity index 70%
rename from libc/bionic/bionic_appcompat.h
rename to linker/linker_transparent_hugepage_support.cpp
index e67e50c..65ba4cd 100644
--- a/libc/bionic/bionic_appcompat.h
+++ b/linker/linker_transparent_hugepage_support.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * Copyright (C) 2021 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,21 +26,19 @@
* SUCH DAMAGE.
*/
-#pragma once
+#include <string>
-constexpr int MAX_PACKAGE_NAME_LENGTH = 230;
+#include <android-base/file.h>
-static inline const char* const soft_mac_bind_allowlist[] = {
- "com.cisco.anyconnect.vpn.android.avf:nchs",
- "com.skype.raider",
- nullptr,
-};
+#include "linker.h"
-static inline const char* const soft_mac_getlink_allowlist[] = {
- "com.cisco.anyconnect.vpn.android.avf:nchs",
- nullptr,
-};
-
-int get_package_name(char* buffer, const int bufferlen);
-bool should_apply_soft_mac_bind_restrictions();
-bool should_apply_soft_mac_getlink_restrictions();
+bool get_transparent_hugepages_supported() {
+ static bool transparent_hugepages_supported = []() {
+ std::string enabled;
+ if (!android::base::ReadFileToString("/sys/kernel/mm/transparent_hugepage/enabled", &enabled)) {
+ return false;
+ }
+ return enabled.find("[never]") == std::string::npos;
+ };
+ return transparent_hugepages_supported;
+}
diff --git a/tests/Android.bp b/tests/Android.bp
index 02a33ee..476b8f5 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -567,6 +567,9 @@
"-Wno-strlcpy-strlcat-size",
"-Wno-strncat-size",
],
+ static_libs: [
+ "libbase",
+ ],
}
cc_defaults {
@@ -575,6 +578,9 @@
"-U_FORTIFY_SOURCE",
],
srcs: ["fortify_test_main.cpp"],
+ static_libs: [
+ "libbase",
+ ],
tidy: false,
target: {
host: {
@@ -839,7 +845,6 @@
],
static_libs: [
// The order of these libraries matters, do not shuffle them.
- "libbase",
"libmeminfo",
"libziparchive",
"libz",
diff --git a/tests/BionicDeathTest.h b/tests/BionicDeathTest.h
deleted file mode 100644
index f70839a..0000000
--- a/tests/BionicDeathTest.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2014 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 <signal.h>
-
-#include <gtest/gtest.h>
-
-#if !defined(__BIONIC__)
-#define sigaction64 sigaction
-#endif
-
-class BionicDeathTest : public testing::Test {
- protected:
- virtual void SetUp() {
- // Suppress debuggerd stack traces. Too slow.
- for (int signo : { SIGABRT, SIGBUS, SIGSEGV, SIGSYS }) {
- struct sigaction64 action = { .sa_handler = SIG_DFL };
- sigaction64(signo, &action, &previous_);
- }
- }
-
- virtual void TearDown() {
- for (int signo : { SIGABRT, SIGBUS, SIGSEGV, SIGSYS }) {
- sigaction64(signo, &previous_, nullptr);
- }
- }
-
- private:
- struct sigaction64 previous_;
-};
diff --git a/tests/arpa_inet_test.cpp b/tests/arpa_inet_test.cpp
index a368b8f..8dec2e3 100644
--- a/tests/arpa_inet_test.cpp
+++ b/tests/arpa_inet_test.cpp
@@ -158,3 +158,95 @@
ASSERT_STREQ("::1", inet_ntop(AF_INET6, &ss6, s6, INET6_ADDRSTRLEN));
ASSERT_STREQ("::1", inet_ntop(AF_INET6, &ss6, s6, 2*INET6_ADDRSTRLEN));
}
+
+TEST(arpa_inet, inet_nsap_addr) {
+ // inet_nsap_addr() doesn't seem to be documented anywhere, but it's basically
+ // text to binary for arbitrarily-long strings like "0xdeadbeef". Any
+ // '.', '+', or '/' characters are ignored as punctuation. The return value is
+ // the length in bytes, or 0 for all errors.
+ u_char buf[32];
+
+ // Missing "0x" prefix.
+ ASSERT_EQ(0U, inet_nsap_addr("123", buf, sizeof(buf)));
+ ASSERT_EQ(0U, inet_nsap_addr("012", buf, sizeof(buf)));
+
+ // 1 byte.
+ ASSERT_EQ(1U, inet_nsap_addr("0x12", buf, sizeof(buf)));
+ ASSERT_EQ(0x12, buf[0]);
+
+ // 10 bytes.
+ ASSERT_EQ(10U, inet_nsap_addr("0x1234567890abcdef0011", buf, sizeof(buf)));
+ ASSERT_EQ(0x12, buf[0]);
+ ASSERT_EQ(0x34, buf[1]);
+ ASSERT_EQ(0x56, buf[2]);
+ ASSERT_EQ(0x78, buf[3]);
+ ASSERT_EQ(0x90, buf[4]);
+ ASSERT_EQ(0xab, buf[5]);
+ ASSERT_EQ(0xcd, buf[6]);
+ ASSERT_EQ(0xef, buf[7]);
+ ASSERT_EQ(0x00, buf[8]);
+ ASSERT_EQ(0x11, buf[9]);
+
+ // Ignored punctuation.
+ ASSERT_EQ(10U, inet_nsap_addr("0x1122.3344+5566/7788/99aa", buf, sizeof(buf)));
+ ASSERT_EQ(0x11, buf[0]);
+ ASSERT_EQ(0x22, buf[1]);
+ ASSERT_EQ(0x33, buf[2]);
+ ASSERT_EQ(0x44, buf[3]);
+ ASSERT_EQ(0x55, buf[4]);
+ ASSERT_EQ(0x66, buf[5]);
+ ASSERT_EQ(0x77, buf[6]);
+ ASSERT_EQ(0x88, buf[7]);
+ ASSERT_EQ(0x99, buf[8]);
+ ASSERT_EQ(0xaa, buf[9]);
+
+ // Truncated.
+ ASSERT_EQ(4U, inet_nsap_addr("0xdeadbeef666666666666", buf, 4));
+ // Overwritten...
+ ASSERT_EQ(0xde, buf[0]);
+ ASSERT_EQ(0xad, buf[1]);
+ ASSERT_EQ(0xbe, buf[2]);
+ ASSERT_EQ(0xef, buf[3]);
+ // Same as before...
+ ASSERT_EQ(0x55, buf[4]);
+ ASSERT_EQ(0x66, buf[5]);
+ ASSERT_EQ(0x77, buf[6]);
+ ASSERT_EQ(0x88, buf[7]);
+ ASSERT_EQ(0x99, buf[8]);
+ ASSERT_EQ(0xaa, buf[9]);
+
+ // Case insensitivity.
+ ASSERT_EQ(6U, inet_nsap_addr("0xaAbBcCdDeEfF", buf, 6));
+ ASSERT_EQ(0xaa, buf[0]);
+ ASSERT_EQ(0xbb, buf[1]);
+ ASSERT_EQ(0xcc, buf[2]);
+ ASSERT_EQ(0xdd, buf[3]);
+ ASSERT_EQ(0xee, buf[4]);
+ ASSERT_EQ(0xff, buf[5]);
+
+ // Punctuation isn't allowed within a byte.
+ ASSERT_EQ(0U, inet_nsap_addr("0x1.122", buf, sizeof(buf)));
+ // Invalid punctuation.
+ ASSERT_EQ(0U, inet_nsap_addr("0x11,22", buf, sizeof(buf)));
+ // Invalid hex digit.
+ ASSERT_EQ(0U, inet_nsap_addr("0x11.g2", buf, sizeof(buf)));
+ ASSERT_EQ(0U, inet_nsap_addr("0x11.2g", buf, sizeof(buf)));
+ // Invalid half-byte.
+ ASSERT_EQ(0U, inet_nsap_addr("0x11.2", buf, sizeof(buf)));
+}
+
+TEST(arpa_inet, inet_nsap_ntoa) {
+ // inet_nsap_ntoa() doesn't seem to be documented anywhere, but it's basically
+ // binary to text for arbitrarily-long byte buffers.
+ // The return value is a pointer to the buffer. No errors are possible.
+ const unsigned char bytes[] = {0x01, 0x00, 0x02, 0x0e, 0xf0, 0x20};
+ char dst[32];
+ ASSERT_EQ(dst, inet_nsap_ntoa(6, bytes, dst));
+ ASSERT_STREQ(dst, "0x01.0002.0EF0.20");
+}
+
+TEST(arpa_inet, inet_nsap_ntoa__nullptr) {
+ // If you don't provide a destination, a static buffer is provided for you.
+ const unsigned char bytes[] = {0x01, 0x00, 0x02, 0x0e, 0xf0, 0x20};
+ ASSERT_STREQ("0x01.0002.0EF0.20", inet_nsap_ntoa(6, bytes, nullptr));
+}
diff --git a/tests/assert_test.cpp b/tests/assert_test.cpp
index 714e22a..769852a 100644
--- a/tests/assert_test.cpp
+++ b/tests/assert_test.cpp
@@ -19,9 +19,9 @@
#undef NDEBUG
#include <assert.h>
-#include "BionicDeathTest.h"
+#include <android-base/silent_death_test.h>
-using assert_DeathTest = BionicDeathTest;
+using assert_DeathTest = SilentDeathTest;
TEST(assert, assert_true) {
assert(true);
diff --git a/tests/cfi_test.cpp b/tests/cfi_test.cpp
index d3cd8d1..9a6ed9a 100644
--- a/tests/cfi_test.cpp
+++ b/tests/cfi_test.cpp
@@ -15,12 +15,13 @@
*/
#include <dlfcn.h>
-#include <gtest/gtest.h>
#include <sys/stat.h>
#include <vector>
-#include "BionicDeathTest.h"
+#include <android-base/silent_death_test.h>
+#include <gtest/gtest.h>
+
#include "gtest_globals.h"
#include "utils.h"
@@ -35,7 +36,7 @@
size_t __cfi_shadow_size();
}
-using cfi_test_DeathTest = BionicDeathTest;
+using cfi_test_DeathTest = SilentDeathTest;
static void f() {}
diff --git a/tests/clang_fortify_tests.cpp b/tests/clang_fortify_tests.cpp
index 0355170..5768f1f 100644
--- a/tests/clang_fortify_tests.cpp
+++ b/tests/clang_fortify_tests.cpp
@@ -94,14 +94,14 @@
#include <wchar.h>
#ifndef COMPILATION_TESTS
+#include <android-base/silent_death_test.h>
#include <gtest/gtest.h>
-#include "BionicDeathTest.h"
#define CONCAT2(x, y) x##y
#define CONCAT(x, y) CONCAT2(x, y)
#define FORTIFY_TEST_NAME CONCAT(CONCAT(clang_fortify_test_, _FORTIFY_SOURCE), _DeathTest)
-using FORTIFY_TEST_NAME = BionicDeathTest;
+using FORTIFY_TEST_NAME = SilentDeathTest;
template <typename Fn>
__attribute__((noreturn)) static void ExitAfter(Fn&& f) {
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index 01c2fe4..47bf133 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -27,9 +27,10 @@
#include <stdint.h>
#include <sys/stat.h>
-#include <string>
-#include <iostream>
#include <fstream>
+#include <iostream>
+#include <regex>
+#include <string>
#include "gtest_globals.h"
#include <android-base/file.h>
@@ -385,7 +386,8 @@
ExecTestHelper eth;
eth.SetArgs({ "readelf", "-SW", path.c_str(), nullptr });
eth.Run([&]() { execvpe("readelf", eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
- ASSERT_TRUE(eth.GetOutput().find(expectation) != std::string::npos) << eth.GetOutput();
+
+ ASSERT_TRUE(std::regex_search(eth.GetOutput(), std::regex(expectation))) << eth.GetOutput();
// Can we load it?
void* handle = dlopen(lib, RTLD_NOW);
@@ -398,31 +400,29 @@
}
TEST(dl, relocations_RELR) {
- RelocationsTest("librelocations-RELR.so",
- ".relr.dyn RELR");
+ RelocationsTest("librelocations-RELR.so", "\\.relr\\.dyn * RELR");
}
TEST(dl, relocations_ANDROID_RELR) {
- RelocationsTest("librelocations-ANDROID_RELR.so",
- ".relr.dyn ANDROID_RELR");
+ RelocationsTest("librelocations-ANDROID_RELR.so", "\\.relr\\.dyn * ANDROID_RELR");
}
TEST(dl, relocations_ANDROID_REL) {
RelocationsTest("librelocations-ANDROID_REL.so",
#if __LP64__
- ".rela.dyn ANDROID_RELA"
+ "\\.rela\\.dyn * ANDROID_RELA"
#else
- ".rel.dyn ANDROID_REL"
+ "\\.rel\\.dyn * ANDROID_REL"
#endif
- );
+ );
}
TEST(dl, relocations_fat) {
RelocationsTest("librelocations-fat.so",
#if __LP64__
- ".rela.dyn RELA"
+ "\\.rela\\.dyn * RELA"
#else
- ".rel.dyn REL"
+ "\\.rel\\.dyn * REL"
#endif
- );
+ );
}
diff --git a/tests/error_test.cpp b/tests/error_test.cpp
index e03c8d4..e114f06 100644
--- a/tests/error_test.cpp
+++ b/tests/error_test.cpp
@@ -30,7 +30,9 @@
#include <error.h>
-#include "BionicDeathTest.h"
+#include <android-base/silent_death_test.h>
+
+using error_DeathTest = SilentDeathTest;
static size_t g_test_error_print_progname_invocation_count;
diff --git a/tests/fdsan_test.cpp b/tests/fdsan_test.cpp
index c294ff3..016970f 100644
--- a/tests/fdsan_test.cpp
+++ b/tests/fdsan_test.cpp
@@ -16,8 +16,6 @@
#include <gtest/gtest.h>
-#include "BionicDeathTest.h"
-
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
@@ -32,6 +30,7 @@
#include <unordered_map>
+#include <android-base/silent_death_test.h>
#include <android-base/unique_fd.h>
#define FDSAN_TEST(test_name) TEST_F(FdsanTest, test_name)
@@ -49,12 +48,12 @@
}
};
-struct fdsan_DeathTest : public BionicDeathTest {
+struct fdsan_DeathTest : public SilentDeathTest {
#if defined(__BIONIC__)
void SetUp() override {
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_FATAL);
signal(BIONIC_SIGNAL_DEBUGGER, SIG_DFL); // Disable debuggerd.
- BionicDeathTest::SetUp();
+ SilentDeathTest::SetUp();
}
#endif
};
diff --git a/tests/fdtrack_test.cpp b/tests/fdtrack_test.cpp
index 13f1b2e..9fcb402 100644
--- a/tests/fdtrack_test.cpp
+++ b/tests/fdtrack_test.cpp
@@ -57,8 +57,13 @@
}
}
-std::vector<android_fdtrack_event> FdtrackRun(void (*func)()) {
+std::vector<android_fdtrack_event> FdtrackRun(void (*func)(), bool reenable = true) {
// Each bionic test is run in separate process, so we can safely use a static here.
+ // However, since they're all forked, we need to reenable fdtrack.
+ if (reenable) {
+ android_fdtrack_set_globally_enabled(true);
+ }
+
static std::vector<android_fdtrack_event> events;
events.clear();
@@ -129,6 +134,21 @@
#endif
}
+TEST(fdtrack, fork) {
+#if defined(__BIONIC__)
+ ASSERT_EXIT(
+ []() {
+ static int fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
+ ASSERT_NE(-1, fd);
+
+ auto events = FdtrackRun([]() { close(fd); }, false);
+ ASSERT_EQ(0U, events.size());
+ exit(0);
+ }(),
+ testing::ExitedWithCode(0), "");
+#endif
+}
+
TEST(fdtrack, enable_disable) {
#if defined(__BIONIC__)
static int fd1 = -1;
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 3ca0223..4abee67 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -15,7 +15,6 @@
*/
#include <gtest/gtest.h>
-#include "BionicDeathTest.h"
#include <fcntl.h>
#include <malloc.h>
@@ -28,6 +27,8 @@
#include <sys/types.h>
#include <time.h>
+#include <android-base/silent_death_test.h>
+
#if __BIONIC__
#define ASSERT_FORTIFY(expr) ASSERT_EXIT(expr, testing::KilledBySignal(SIGABRT), "FORTIFY")
#else
@@ -40,7 +41,7 @@
#define DEATHTEST_EVALUATOR(name) DEATHTEST_PASTER(name)
#define DEATHTEST DEATHTEST_EVALUATOR(TEST_NAME)
-class DEATHTEST : public BionicDeathTest {};
+using DEATHTEST = SilentDeathTest;
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE == 2
struct foo {
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
index 1dd45b4..9f7e65b 100644
--- a/tests/math_test.cpp
+++ b/tests/math_test.cpp
@@ -1473,16 +1473,40 @@
ASSERT_EQ(-1, sign);
}
+TEST(MATH_TEST, tgamma_NaN) {
+ ASSERT_TRUE(isnan(tgamma(nan(""))));
+ ASSERT_TRUE(isnanf(tgammaf(nanf(""))));
+ ASSERT_TRUE(isnanl(tgammal(nanl(""))));
+}
+
+TEST(MATH_TEST, tgamma_inf) {
+ ASSERT_TRUE(isinf(tgamma(HUGE_VAL)));
+ ASSERT_TRUE(isinff(tgammaf(HUGE_VALF)));
+ ASSERT_TRUE(isinfl(tgammal(HUGE_VALL)));
+}
+
+TEST(MATH_TEST, tgamma_negative) {
+ ASSERT_TRUE(isnan(tgamma(-1.0)));
+ ASSERT_TRUE(isnanf(tgammaf(-1.0f)));
+ ASSERT_TRUE(isnanl(tgammal(-1.0L)));
+}
+
TEST(MATH_TEST, tgamma) {
ASSERT_DOUBLE_EQ(24.0, tgamma(5.0));
+ ASSERT_DOUBLE_EQ(120.0, tgamma(6.0));
+ ASSERT_TRUE(isinf(tgamma(172.0)));
}
TEST(MATH_TEST, tgammaf) {
ASSERT_FLOAT_EQ(24.0f, tgammaf(5.0f));
+ ASSERT_FLOAT_EQ(120.0f, tgammaf(6.0f));
+ ASSERT_TRUE(isinff(tgammaf(172.0f)));
}
TEST(MATH_TEST, tgammal) {
ASSERT_DOUBLE_EQ(24.0L, tgammal(5.0L));
+ ASSERT_DOUBLE_EQ(120.0L, tgammal(6.0L));
+ ASSERT_TRUE(isinf(tgammal(172.0L)));
}
TEST(MATH_TEST, j0) {
diff --git a/tests/pidfd_test.cpp b/tests/pidfd_test.cpp
index 7c691ef..b9fadb4 100644
--- a/tests/pidfd_test.cpp
+++ b/tests/pidfd_test.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include <gtest/gtest.h>
+
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
@@ -24,16 +26,13 @@
#include <sys/pidfd.h>
#endif
+#include <android-base/silent_death_test.h>
#include <android-base/unique_fd.h>
-#include <gtest/gtest.h>
-
-#include "BionicDeathTest.h"
-
using android::base::unique_fd;
using namespace std::chrono_literals;
-using pidfd_DeathTest = BionicDeathTest;
+using pidfd_DeathTest = SilentDeathTest;
TEST(pidfd, pidfd_open) {
#if defined(__BIONIC__)
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 1cbe3de..1a00460 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -38,14 +38,14 @@
#include <android-base/macros.h>
#include <android-base/parseint.h>
#include <android-base/scopeguard.h>
+#include <android-base/silent_death_test.h>
#include <android-base/strings.h>
#include "private/bionic_constants.h"
-#include "BionicDeathTest.h"
#include "SignalUtils.h"
#include "utils.h"
-using pthread_DeathTest = BionicDeathTest;
+using pthread_DeathTest = SilentDeathTest;
TEST(pthread, pthread_key_create) {
pthread_key_t key;
diff --git a/tests/semaphore_test.cpp b/tests/semaphore_test.cpp
index ed0fcf1..f3f6020 100644
--- a/tests/semaphore_test.cpp
+++ b/tests/semaphore_test.cpp
@@ -17,17 +17,18 @@
#include <semaphore.h>
#include <errno.h>
-#include <gtest/gtest.h>
#include <limits.h>
#include <pthread.h>
#include <time.h>
#include <unistd.h>
-#include "BionicDeathTest.h"
+#include <android-base/silent_death_test.h>
+#include <gtest/gtest.h>
+
#include "SignalUtils.h"
#include "private/bionic_constants.h"
-using semaphore_DeathTest = BionicDeathTest;
+using semaphore_DeathTest = SilentDeathTest;
TEST(semaphore, sem_init) {
sem_t s;
diff --git a/tests/setjmp_test.cpp b/tests/setjmp_test.cpp
index e6b6819..ee126eb 100644
--- a/tests/setjmp_test.cpp
+++ b/tests/setjmp_test.cpp
@@ -18,11 +18,14 @@
#include <setjmp.h>
#include <stdlib.h>
+#include <sys/syscall.h>
+#include <unistd.h>
-#include "BionicDeathTest.h"
+#include <android-base/silent_death_test.h>
+
#include "SignalUtils.h"
-using setjmp_DeathTest = BionicDeathTest;
+using setjmp_DeathTest = SilentDeathTest;
TEST(setjmp, setjmp_smoke) {
int value;
@@ -268,3 +271,57 @@
if (value == 0) call_longjmp(buf);
EXPECT_EQ(123, value);
}
+
+TEST(setjmp, bug_152210274) {
+ // Ensure that we never have a mangled value in the stack pointer.
+#if defined(__BIONIC__)
+ struct sigaction sa = {.sa_flags = SA_SIGINFO, .sa_sigaction = [](int, siginfo_t*, void*) {}};
+ ASSERT_EQ(0, sigaction(SIGPROF, &sa, 0));
+
+ constexpr size_t kNumThreads = 20;
+
+ // Start a bunch of threads calling setjmp/longjmp.
+ auto jumper = [](void* arg) -> void* {
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGPROF);
+ pthread_sigmask(SIG_UNBLOCK, &set, nullptr);
+
+ jmp_buf buf;
+ for (size_t count = 0; count < 100000; ++count) {
+ if (setjmp(buf) != 0) {
+ perror("setjmp");
+ abort();
+ }
+ if (*static_cast<pid_t*>(arg) == 100) longjmp(buf, 1);
+ }
+ return nullptr;
+ };
+ pid_t tids[kNumThreads] = {};
+ for (size_t i = 0; i < kNumThreads; ++i) {
+ pthread_t t;
+ ASSERT_EQ(0, pthread_create(&t, nullptr, jumper, &tids[i]));
+ tids[i] = pthread_gettid_np(t);
+ }
+
+ // Start the interrupter thread.
+ auto interrupter = [](void* arg) -> void* {
+ pid_t* tids = static_cast<pid_t*>(arg);
+ for (size_t count = 0; count < 1000; ++count) {
+ for (size_t i = 0; i < kNumThreads; i++) {
+ if (tgkill(getpid(), tids[i], SIGPROF) == -1 && errno != ESRCH) {
+ perror("tgkill failed");
+ abort();
+ }
+ }
+ usleep(100);
+ }
+ return nullptr;
+ };
+ pthread_t t;
+ ASSERT_EQ(0, pthread_create(&t, nullptr, interrupter, tids));
+ pthread_join(t, nullptr);
+#else
+ GTEST_SKIP() << "tests uses functions not in glibc";
+#endif
+}
diff --git a/tests/stack_protector_test.cpp b/tests/stack_protector_test.cpp
index 9fe7bb1..a95e037 100644
--- a/tests/stack_protector_test.cpp
+++ b/tests/stack_protector_test.cpp
@@ -19,7 +19,6 @@
*/
#include <gtest/gtest.h>
-#include "BionicDeathTest.h"
#include <pthread.h>
#include <stdint.h>
@@ -27,6 +26,8 @@
#include <unistd.h>
#include <set>
+#include <android-base/silent_death_test.h>
+
#include "private/bionic_tls.h"
extern "C" pid_t gettid(); // glibc defines this but doesn't declare it anywhere.
@@ -99,7 +100,7 @@
#endif
}
-class stack_protector_DeathTest : public BionicDeathTest {};
+using stack_protector_DeathTest = SilentDeathTest;
TEST_F(stack_protector_DeathTest, modify_stack_protector) {
// In another file to prevent inlining, which removes stack protection.
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 5491589..5736e17 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -33,10 +33,10 @@
#include <vector>
#include <android-base/file.h>
+#include <android-base/silent_death_test.h>
#include <android-base/test_utils.h>
#include <android-base/unique_fd.h>
-#include "BionicDeathTest.h"
#include "utils.h"
// This #include is actually a test too. We have to duplicate the
@@ -56,8 +56,8 @@
using namespace std::string_literals;
-using stdio_DeathTest = BionicDeathTest;
-using stdio_nofortify_DeathTest = BionicDeathTest;
+using stdio_DeathTest = SilentDeathTest;
+using stdio_nofortify_DeathTest = SilentDeathTest;
static void SetFileTo(const char* path, const char* content) {
FILE* fp;
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 90ef861..6c7966d 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -31,9 +31,9 @@
#include <android-base/file.h>
#include <android-base/macros.h>
+#include <android-base/silent_death_test.h>
#include <gtest/gtest.h>
-#include "BionicDeathTest.h"
#include "math_data_test.h"
#include "utils.h"
@@ -447,7 +447,7 @@
// Even though this isn't really a death test, we have to say "DeathTest" here so gtest knows to
// run this test (which exits normally) in its own process.
-class stdlib_DeathTest : public BionicDeathTest {};
+using stdlib_DeathTest = SilentDeathTest;
TEST_F(stdlib_DeathTest, getenv_after_main_thread_exits) {
// https://code.google.com/p/android/issues/detail?id=57421
diff --git a/tests/system_properties_test.cpp b/tests/system_properties_test.cpp
index 6d696c7..aa8fef4 100644
--- a/tests/system_properties_test.cpp
+++ b/tests/system_properties_test.cpp
@@ -15,7 +15,6 @@
*/
#include <gtest/gtest.h>
-#include "BionicDeathTest.h"
#include <errno.h>
#include <sys/wait.h>
@@ -25,6 +24,7 @@
#include <thread>
#include <android-base/file.h>
+#include <android-base/silent_death_test.h>
using namespace std::literals;
@@ -425,7 +425,7 @@
WTERMSIG(exit_status) == SIGABRT);
}
-class properties_DeathTest : public BionicDeathTest {};
+using properties_DeathTest = SilentDeathTest;
TEST_F(properties_DeathTest, read_only) {
#if defined(__BIONIC__)
diff --git a/tests/threads_test.cpp b/tests/threads_test.cpp
index 5fafff3..c1e9b12 100644
--- a/tests/threads_test.cpp
+++ b/tests/threads_test.cpp
@@ -60,7 +60,8 @@
#include <thread>
-#include "BionicDeathTest.h"
+#include <android-base/silent_death_test.h>
+
#include "SignalUtils.h"
TEST(threads, call_once) {
@@ -361,7 +362,7 @@
#endif
}
-class threads_DeathTest : public BionicDeathTest {};
+using threads_DeathTest = SilentDeathTest;
TEST(threads_DeathTest, thrd_exit_main_thread) {
#if !defined(HAVE_THREADS_H)
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 7c2c890..b16fe16 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -31,8 +31,6 @@
#include "SignalUtils.h"
#include "utils.h"
-#include "private/bionic_constants.h"
-
using namespace std::chrono_literals;
TEST(time, time) {
@@ -760,22 +758,22 @@
TEST(time, clock_gettime) {
// Try to ensure that our vdso clock_gettime is working.
+ timespec ts0;
timespec ts1;
- ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, &ts1));
timespec ts2;
- ASSERT_EQ(0, syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &ts2));
+ ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, &ts0));
+ ASSERT_EQ(0, syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &ts1));
+ ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, &ts2));
- // What's the difference between the two?
- ts2.tv_sec -= ts1.tv_sec;
- ts2.tv_nsec -= ts1.tv_nsec;
- if (ts2.tv_nsec < 0) {
- --ts2.tv_sec;
- ts2.tv_nsec += NS_PER_S;
+ // Check we have a nice monotonic timestamp sandwich.
+ ASSERT_LE(ts0.tv_sec, ts1.tv_sec);
+ if (ts0.tv_sec == ts1.tv_sec) {
+ ASSERT_LE(ts0.tv_nsec, ts1.tv_nsec);
}
-
- // To try to avoid flakiness we'll accept answers within 10,000,000ns (0.01s).
- ASSERT_EQ(0, ts2.tv_sec);
- ASSERT_LT(ts2.tv_nsec, 10'000'000);
+ ASSERT_LE(ts1.tv_sec, ts2.tv_sec);
+ if (ts1.tv_sec == ts2.tv_sec) {
+ ASSERT_LE(ts1.tv_nsec, ts2.tv_nsec);
+ }
}
TEST(time, clock_gettime_CLOCK_REALTIME) {
@@ -851,11 +849,15 @@
}
TEST(time, clock) {
- // clock(3) is hard to test, but a 1s sleep should cost less than 20ms.
+ // clock(3) is hard to test, but a 1s sleep should cost less than 10ms on average.
+ static const clock_t N = 5;
+ static const clock_t mean_limit_ms = 10;
clock_t t0 = clock();
- sleep(1);
+ for (size_t i = 0; i < N; ++i) {
+ sleep(1);
+ }
clock_t t1 = clock();
- ASSERT_LT(t1 - t0, 20 * (CLOCKS_PER_SEC / 1000));
+ ASSERT_LT(t1 - t0, N * mean_limit_ms * (CLOCKS_PER_SEC / 1000));
}
static pid_t GetInvalidPid() {
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index 595ba90..7d1e612 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -16,7 +16,6 @@
#include <gtest/gtest.h>
-#include "BionicDeathTest.h"
#include "SignalUtils.h"
#include "utils.h"
@@ -37,6 +36,7 @@
#include <chrono>
#include <android-base/file.h>
+#include <android-base/silent_death_test.h>
#include <android-base/strings.h>
#include "private/get_cpu_count_from_string.h"
@@ -53,6 +53,8 @@
#define UNISTD_DEATHTEST unistd_DeathTest
#endif
+using UNISTD_DEATHTEST = SilentDeathTest;
+
using namespace std::chrono_literals;
static void* get_brk() {
@@ -711,8 +713,6 @@
}
}
-class UNISTD_DEATHTEST : public BionicDeathTest {};
-
TEST_F(UNISTD_DEATHTEST, abort) {
ASSERT_EXIT(abort(), testing::KilledBySignal(SIGABRT), "");
}
diff --git a/tests/wchar_test.cpp b/tests/wchar_test.cpp
index 9b4fc4f..d0b5a4a 100644
--- a/tests/wchar_test.cpp
+++ b/tests/wchar_test.cpp
@@ -228,14 +228,22 @@
}
TEST(wchar, wcsstr) {
- const wchar_t* haystack = L"matches hello world, not the second hello world";
- const wchar_t* empty_needle = L"";
- const wchar_t* good_needle = L"ll";
- const wchar_t* bad_needle = L"wort";
+ const wchar_t* haystack = L"big daddy/giant haystacks!";
+ const wchar_t* empty_haystack = L"";
- ASSERT_EQ(haystack, wcsstr(haystack, empty_needle));
- ASSERT_EQ(&haystack[10], wcsstr(haystack, good_needle));
- ASSERT_EQ(nullptr, wcsstr(haystack, bad_needle));
+ // The empty needle is a special case.
+ ASSERT_EQ(haystack, wcsstr(haystack, L""));
+ ASSERT_EQ(empty_haystack, wcsstr(empty_haystack, L""));
+
+ ASSERT_EQ(haystack, wcsstr(haystack, L"b"));
+ ASSERT_EQ(haystack, wcsstr(haystack, L"big"));
+ ASSERT_EQ(haystack + 9, wcsstr(haystack, L"/"));
+ ASSERT_EQ(haystack + 9, wcsstr(haystack, L"/giant"));
+ ASSERT_EQ(haystack + 25, wcsstr(haystack, L"!"));
+ ASSERT_EQ(haystack + 19, wcsstr(haystack, L"stacks!"));
+
+ ASSERT_EQ(nullptr, wcsstr(haystack, L"monkey"));
+ ASSERT_EQ(nullptr, wcsstr(empty_haystack, L"monkey"));
}
TEST(wchar, wcsstr_80199) {
@@ -646,6 +654,8 @@
EXPECT_EQ(dst, wcsncpy(dst, src, 6));
dst[6] = L'\0';
EXPECT_STREQ(dst, L"Source");
+ EXPECT_EQ(dst, wcsncpy(dst, L"clobber", 0));
+ EXPECT_STREQ(dst, L"Source");
wmemset(dst, L'x', NUM_WCHARS(sizeof(dst)));
EXPECT_EQ(dst, wcsncpy(dst, src, src_len + 4));
@@ -1024,3 +1034,169 @@
EXPECT_EQ(2, wcwidth(L'ㅜ')); // Korean "crying" emoticon.
EXPECT_EQ(2, wcwidth(L'ㅋ')); // Korean "laughing" emoticon.
}
+
+TEST(wchar, wcswidth) {
+ EXPECT_EQ(2, wcswidth(L"abc", 2));
+ EXPECT_EQ(2, wcswidth(L"ab\t", 2));
+ EXPECT_EQ(-1, wcswidth(L"a\tb", 2));
+}
+
+TEST(wchar, wcslcpy) {
+#if defined(__BIONIC__)
+ wchar_t dst[32];
+ ASSERT_EQ(11U, wcslcpy(dst, L"hello world", 3));
+ ASSERT_STREQ(L"he", dst);
+ ASSERT_EQ(11U, wcslcpy(dst, L"hello world", 32));
+ ASSERT_STREQ(L"hello world", dst);
+#else
+ GTEST_SKIP() << "no wcslcpy in glibc";
+#endif
+}
+
+TEST(wchar, wcscat) {
+ wchar_t dst[32];
+ ASSERT_EQ(dst, wcscat(dst, L"hello"));
+ ASSERT_STREQ(dst, L"hello");
+ ASSERT_EQ(dst, wcscat(dst, L" world"));
+ ASSERT_STREQ(dst, L"hello world");
+}
+
+TEST(wchar, wcscpy) {
+ wchar_t dst[32];
+ ASSERT_EQ(dst, wcscpy(dst, L"hello"));
+ ASSERT_STREQ(dst, L"hello");
+ ASSERT_EQ(dst, wcscpy(dst, L"world"));
+ ASSERT_STREQ(dst, L"world");
+}
+
+TEST(wchar, wcscasecmp) {
+ ASSERT_EQ(0, wcscasecmp(L"hello", L"HELLO"));
+ ASSERT_TRUE(wcscasecmp(L"hello1", L"HELLO2") < 0);
+ ASSERT_TRUE(wcscasecmp(L"hello2", L"HELLO1") > 0);
+ ASSERT_TRUE(wcscasecmp(L"hello", L"HELL") > 0);
+ ASSERT_TRUE(wcscasecmp(L"hell", L"HELLO") < 0);
+}
+
+TEST(wchar, wcscspn) {
+ ASSERT_EQ(0U, wcscspn(L"hello world", L"abcdefghijklmnopqrstuvwxyz"));
+ ASSERT_EQ(5U, wcscspn(L"hello world", L" "));
+ ASSERT_EQ(11U, wcscspn(L"hello world", L"!"));
+}
+
+TEST(wchar, wcsspn) {
+ ASSERT_EQ(0U, wcsspn(L"hello world", L"!"));
+ ASSERT_EQ(5U, wcsspn(L"hello world", L"abcdefghijklmnopqrstuvwxyz"));
+ ASSERT_EQ(11U, wcsspn(L"hello world", L"abcdefghijklmnopqrstuvwxyz "));
+}
+
+TEST(wchar, wcsdup) {
+ wchar_t* s = wcsdup(L"hello");
+ ASSERT_STREQ(s, L"hello");
+ free(s);
+}
+
+TEST(wchar, wcslcat) {
+#if defined(__BIONIC__)
+ wchar_t dst[4] = {};
+ ASSERT_EQ(1U, wcslcat(dst, L"a", 4));
+ ASSERT_EQ(7U, wcslcat(dst, L"bcdefg", 4));
+ ASSERT_STREQ(dst, L"abc");
+#else
+ GTEST_SKIP() << "no wcslcpy in glibc";
+#endif
+}
+
+TEST(wchar, wcsncasecmp) {
+ ASSERT_EQ(0, wcsncasecmp(L"foo", L"bar", 0));
+
+ ASSERT_EQ(0, wcsncasecmp(L"hello1", L"HELLO2", 5));
+ ASSERT_TRUE(wcsncasecmp(L"hello1", L"HELLO2", 6) < 0);
+ ASSERT_TRUE(wcsncasecmp(L"hello2", L"HELLO1", 6) > 0);
+ ASSERT_TRUE(wcsncasecmp(L"hello", L"HELL", 5) > 0);
+ ASSERT_TRUE(wcsncasecmp(L"hell", L"HELLO", 5) < 0);
+}
+
+TEST(wchar, wcsncat) {
+ wchar_t dst[32];
+ ASSERT_EQ(dst, wcsncat(dst, L"hello, world!", 5));
+ ASSERT_STREQ(dst, L"hello");
+ ASSERT_EQ(dst, wcsncat(dst, L"hello, world!", 0));
+ ASSERT_STREQ(dst, L"hello");
+ ASSERT_EQ(dst, wcsncat(dst, L", world!", 8));
+ ASSERT_STREQ(dst, L"hello, world!");
+}
+
+TEST(wchar, wcsncmp) {
+ ASSERT_EQ(0, wcsncmp(L"foo", L"bar", 0));
+ ASSERT_EQ(0, wcsncmp(L"aaaa", L"aaab", 3));
+ ASSERT_TRUE(wcsncmp(L"aaaa", L"aaab", 4) < 0);
+ ASSERT_TRUE(wcsncmp(L"aaab", L"aaaa", 4) > 0);
+}
+
+TEST(wchar, wcsnlen) {
+ ASSERT_EQ(2U, wcsnlen(L"hello", 2));
+ ASSERT_EQ(5U, wcsnlen(L"hello", 5));
+ ASSERT_EQ(5U, wcsnlen(L"hello", 666));
+}
+
+TEST(wchar, wcspbrk) {
+ const wchar_t* s = L"hello, world!";
+ ASSERT_EQ(nullptr, wcspbrk(s, L"-"));
+ ASSERT_EQ(s, wcspbrk(s, L"abch"));
+ ASSERT_EQ(s + 2, wcspbrk(s, L"l"));
+ ASSERT_EQ(s + 5, wcspbrk(s, L",. !"));
+}
+
+TEST(wchar, wcstok) {
+ wchar_t s[] = L"this is\ta\nstring";
+ wchar_t* p;
+ ASSERT_EQ(s, wcstok(s, L"\t\n ", &p));
+ ASSERT_STREQ(s, L"this");
+ ASSERT_STREQ(p, L"is\ta\nstring");
+ ASSERT_EQ(s + 5, wcstok(nullptr, L"\t\n ", &p));
+ ASSERT_STREQ(s + 5, L"is");
+ ASSERT_STREQ(p, L"a\nstring");
+ ASSERT_EQ(s + 8, wcstok(nullptr, L"\t\n ", &p));
+ ASSERT_STREQ(s + 8, L"a");
+ ASSERT_STREQ(p, L"string");
+ ASSERT_EQ(s + 10, wcstok(nullptr, L"\t\n ", &p));
+ ASSERT_STREQ(s + 10, L"string");
+ ASSERT_EQ(nullptr, p);
+}
+
+TEST(wchar, wmemchr) {
+ const wchar_t* s = L"hello, world!";
+ ASSERT_EQ(s, wmemchr(s, L'h', 13));
+ ASSERT_EQ(s + 5, wmemchr(s, L',', 13));
+ ASSERT_EQ(s + 12, wmemchr(s, L'!', 13));
+ ASSERT_EQ(nullptr, wmemchr(s, L'a', 13));
+}
+
+TEST(wchar, wmemcmp) {
+ ASSERT_EQ(0, wmemcmp(L"aaaa", L"aaab", 3));
+ ASSERT_TRUE(wmemcmp(L"aaaa", L"aaab", 4) < 0);
+ ASSERT_TRUE(wmemcmp(L"aaab", L"aaaa", 4) > 0);
+}
+
+TEST(wchar, wmemcpy) {
+ wchar_t dst[32] = {};
+ ASSERT_EQ(dst, wmemcpy(dst, L"hello", 5));
+ ASSERT_STREQ(dst, L"hello");
+}
+
+TEST(wchar, wmemmove) {
+ wchar_t dst[32] = {};
+ ASSERT_EQ(dst, wmemmove(dst, L"hello", 5));
+ ASSERT_STREQ(dst, L"hello");
+}
+
+TEST(wchar, wmemset) {
+ wchar_t dst[4] = {};
+ ASSERT_EQ(dst, wmemset(dst, 0x12345678, 3));
+ ASSERT_EQ(dst[0], wchar_t(0x12345678));
+ ASSERT_EQ(dst[1], wchar_t(0x12345678));
+ ASSERT_EQ(dst[2], wchar_t(0x12345678));
+ ASSERT_EQ(dst[3], wchar_t(0));
+ ASSERT_EQ(dst, wmemset(dst, L'y', 0));
+ ASSERT_EQ(dst[0], wchar_t(0x12345678));
+}
diff --git a/tools/generate-version-script.py b/tools/generate-version-script.py
index acfe218..def621e 100755
--- a/tools/generate-version-script.py
+++ b/tools/generate-version-script.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# This tool is used to generate the version scripts for libc, libm, libdl,
# and libstdc++ for every architecture.
diff --git a/tools/versioner/run_tests.py b/tools/versioner/run_tests.py
index f3bb6db..396f895 100755
--- a/tools/versioner/run_tests.py
+++ b/tools/versioner/run_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
import os
import subprocess