mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-23 22:06:12 +03:00
Fix recommitted pages not being zeroed when madvise is not available.
This commit is contained in:
parent
978ff90c36
commit
0fc7bef6da
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -404,7 +404,7 @@ jobs:
|
||||
- arch: aarch64_cortex-a53-static
|
||||
openwrt: 'target=sunxi subtarget=cortexa53'
|
||||
target_cpu: arm64
|
||||
extra: 'arm_cpu="cortex-a53" build_static=true'
|
||||
extra: 'arm_cpu="cortex-a53" build_static=true no_madvise_syscall=true'
|
||||
- arch: aarch64_cortex-a72
|
||||
openwrt: 'target=mvebu subtarget=cortexa72'
|
||||
target_cpu: arm64
|
||||
@ -443,7 +443,7 @@ jobs:
|
||||
- arch: arm_cortex-a7_neon-vfpv4-static
|
||||
openwrt: 'target=sunxi subtarget=cortexa7'
|
||||
target_cpu: arm
|
||||
extra: 'arm_version=0 arm_cpu="cortex-a7" arm_fpu="neon-vfpv4" arm_float_abi="hard" arm_use_neon=true build_static=true'
|
||||
extra: 'arm_version=0 arm_cpu="cortex-a7" arm_fpu="neon-vfpv4" arm_float_abi="hard" arm_use_neon=true build_static=true no_madvise_syscall=true'
|
||||
- arch: arm_cortex-a8_vfpv3
|
||||
openwrt: 'target=sunxi subtarget=cortexa8'
|
||||
target_cpu: arm
|
||||
@ -455,7 +455,7 @@ jobs:
|
||||
- arch: arm_cortex-a9-static
|
||||
openwrt: 'target=bcm53xx subtarget=generic'
|
||||
target_cpu: arm
|
||||
extra: 'arm_version=0 arm_cpu="cortex-a9" arm_float_abi="soft" arm_use_neon=false build_static=true'
|
||||
extra: 'arm_version=0 arm_cpu="cortex-a9" arm_float_abi="soft" arm_use_neon=false build_static=true no_madvise_syscall=true'
|
||||
- arch: arm_cortex-a9_neon
|
||||
openwrt: 'target=zynq subtarget=generic'
|
||||
target_cpu: arm
|
||||
@ -479,7 +479,7 @@ jobs:
|
||||
- arch: mipsel_24kc-static
|
||||
openwrt: 'target=ramips subtarget=rt305x'
|
||||
target_cpu: mipsel
|
||||
extra: 'mips_arch_variant="r2" mips_float_abi="soft" build_static=true'
|
||||
extra: 'mips_arch_variant="r2" mips_float_abi="soft" build_static=true no_madvise_syscall=true'
|
||||
- arch: mipsel_mips32
|
||||
openwrt: 'target=bcm47xx subtarget=generic'
|
||||
target_cpu: mipsel
|
||||
|
@ -260,6 +260,8 @@ constexpr PA_COMPONENT_EXPORT(
|
||||
PARTITION_ALLOC) bool DecommittedMemoryIsAlwaysZeroed() {
|
||||
#if BUILDFLAG(IS_APPLE)
|
||||
return false;
|
||||
#elif defined(NO_MADVISE_SYSCALL)
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
@ -410,6 +410,9 @@ void DiscardSystemPagesInternal(uintptr_t address, size_t length) {
|
||||
ret = madvise(ptr, length, MADV_DONTNEED);
|
||||
}
|
||||
PA_PCHECK(ret == 0);
|
||||
#elif defined(NO_MADVISE_SYSCALL)
|
||||
static_cast<void>(ptr);
|
||||
static_cast<void>(length);
|
||||
#else // BUILDFLAG(IS_APPLE)
|
||||
// We have experimented with other flags, but with suboptimal results.
|
||||
//
|
||||
@ -417,12 +420,7 @@ void DiscardSystemPagesInternal(uintptr_t address, size_t length) {
|
||||
// performance benefits unclear.
|
||||
//
|
||||
// Therefore, we just do the simple thing: MADV_DONTNEED.
|
||||
int ret = madvise(ptr, length, MADV_DONTNEED);
|
||||
if (ret && errno == ENOSYS) {
|
||||
// Ignores when the kernel is built without CONFIG_ADVISE_SYSCALLS
|
||||
return;
|
||||
}
|
||||
PA_PCHECK(ret == 0);
|
||||
PA_PCHECK(0 == madvise(ptr, length, MADV_DONTNEED));
|
||||
#endif // BUILDFLAG(IS_APPLE)
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@ assert(current_os == "openwrt")
|
||||
|
||||
declare_args() {
|
||||
build_static = false
|
||||
|
||||
no_madvise_syscall = false
|
||||
}
|
||||
|
||||
# This is included by reference in the //build/config/compiler config that
|
||||
@ -39,6 +41,10 @@ config("compiler") {
|
||||
ldflags += [ "-Wl,--dynamic-linker=/lib/ld-musl-mipsel-sf.so.1" ]
|
||||
}
|
||||
|
||||
if (no_madvise_syscall) {
|
||||
defines += [ "NO_MADVISE_SYSCALL" ]
|
||||
}
|
||||
|
||||
abi = "musl"
|
||||
if (current_cpu == "arm") {
|
||||
abi = "muslgnueabi"
|
||||
|
Loading…
Reference in New Issue
Block a user