qemu: Bump to 7.2.0
Include workaround for https://github.com/termux/termux-packages/issues/12261.
This commit is contained in:
parent
fe28a98aee
commit
223ca7cc5e
|
@ -2,14 +2,14 @@ diff -uNr qemu-6.1.0/block.c qemu-6.1.0.mod/block.c
|
|||
--- qemu-6.1.0/block.c 2021-08-24 20:35:40.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/block.c 2021-08-25 15:22:26.469952602 +0300
|
||||
@@ -833,7 +833,7 @@
|
||||
const char *tmpdir;
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) {
|
||||
* /var/tmp is usually on a disk, so more appropriate for disk images.
|
||||
*/
|
||||
if (!g_strcmp0(tmpdir, "/tmp")) {
|
||||
- tmpdir = "/var/tmp";
|
||||
+ tmpdir = "@TERMUX_PREFIX@/tmp";
|
||||
}
|
||||
if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) {
|
||||
return -EOVERFLOW;
|
||||
#endif
|
||||
|
||||
diff -uNr qemu-6.1.0/hw/hppa/machine.c qemu-6.1.0.mod/hw/hppa/machine.c
|
||||
--- qemu-6.1.0/hw/hppa/machine.c 2021-08-24 20:35:40.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/hw/hppa/machine.c 2021-08-25 15:22:26.469952602 +0300
|
||||
|
@ -122,31 +122,6 @@ diff -uNr qemu-6.1.0/qemu-nbd.c qemu-6.1.0.mod/qemu-nbd.c
|
|||
}
|
||||
|
||||
server = qio_net_listener_new();
|
||||
diff -uNr qemu-6.1.0/slirp/src/slirp.c qemu-6.1.0.mod/slirp/src/slirp.c
|
||||
--- qemu-6.1.0/slirp/src/slirp.c 2021-08-24 20:36:28.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/slirp/src/slirp.c 2021-08-25 15:23:17.110356661 +0300
|
||||
@@ -221,7 +221,7 @@
|
||||
#if defined(__HAIKU__)
|
||||
#define RESOLV_CONF_PATH "/boot/system/settings/network/resolv.conf"
|
||||
#else
|
||||
-#define RESOLV_CONF_PATH "/etc/resolv.conf"
|
||||
+#define RESOLV_CONF_PATH "@TERMUX_PREFIX@/etc/resolv.conf"
|
||||
#endif
|
||||
|
||||
static int get_dns_addr_cached(void *pdns_addr, void *cached_addr,
|
||||
diff -uNr qemu-6.1.0/tcg/tcg.c qemu-6.1.0.mod/tcg/tcg.c
|
||||
--- qemu-6.1.0/tcg/tcg.c 2021-08-24 20:35:41.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/tcg/tcg.c 2021-08-25 15:22:26.485952693 +0300
|
||||
@@ -4684,7 +4684,8 @@
|
||||
/* Enable this block to be able to debug the ELF image file creation.
|
||||
One can use readelf, objdump, or other inspection utilities. */
|
||||
{
|
||||
- FILE *f = fopen("/tmp/qemu.jit", "w+b");
|
||||
+ FILE *f = fopen("@TERMUX_PREFIX@/tmp/qemu.jit", "w+b");
|
||||
+
|
||||
if (f) {
|
||||
if (fwrite(img, img_size, 1, f) != img_size) {
|
||||
/* Avoid stupid unused return value warning for fwrite. */
|
||||
diff -uNr qemu-6.1.0/util/module.c qemu-6.1.0.mod/util/module.c
|
||||
--- qemu-6.1.0/util/module.c 2021-08-24 20:35:41.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/util/module.c 2021-08-25 15:22:26.485952693 +0300
|
||||
|
@ -159,15 +134,3 @@ diff -uNr qemu-6.1.0/util/module.c qemu-6.1.0.mod/util/module.c
|
|||
#endif
|
||||
|
||||
assert(n_dirs <= ARRAY_SIZE(dirs));
|
||||
diff -uNr qemu-6.1.0/util/qemu-sockets.c qemu-6.1.0.mod/util/qemu-sockets.c
|
||||
--- qemu-6.1.0/util/qemu-sockets.c 2021-08-24 20:35:41.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/util/qemu-sockets.c 2021-08-25 15:22:26.485952693 +0300
|
||||
@@ -923,7 +923,7 @@
|
||||
path = saddr->path;
|
||||
} else {
|
||||
const char *tmpdir = getenv("TMPDIR");
|
||||
- tmpdir = tmpdir ? tmpdir : "/tmp";
|
||||
+ tmpdir = tmpdir ? tmpdir : "@TERMUX_PREFIX@/tmp";
|
||||
path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ diff -uNr qemu-6.1.0/meson.build qemu-6.1.0.mod/meson.build
|
|||
--- qemu-6.1.0/meson.build 2021-08-25 21:20:39.873631512 +0300
|
||||
+++ qemu-6.1.0.mod/meson.build 2021-08-25 21:21:35.135670419 +0300
|
||||
@@ -1785,10 +1785,6 @@
|
||||
CPU_FREE(cpuset);
|
||||
return 0;
|
||||
}''', dependencies: threads))
|
||||
|
||||
-config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
|
||||
- #include <sys/signalfd.h>
|
||||
- #include <stddef.h>
|
||||
|
|
|
@ -2,11 +2,10 @@ TERMUX_PKG_HOMEPAGE=https://www.qemu.org
|
|||
TERMUX_PKG_DESCRIPTION="A generic and open source machine emulator and virtualizer (headless)"
|
||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=1:7.1.0
|
||||
TERMUX_PKG_REVISION=1
|
||||
TERMUX_PKG_VERSION=1:7.2.0
|
||||
TERMUX_PKG_SRCURL=https://download.qemu.org/qemu-${TERMUX_PKG_VERSION:2}.tar.xz
|
||||
TERMUX_PKG_SHA256=a0634e536bded57cf38ec8a751adb124b89c776fe0846f21ab6c6728f1cbbbe6
|
||||
TERMUX_PKG_DEPENDS="glib, libbz2, libc++, libcurl, libgnutls, libiconv, libjpeg-turbo, liblzo, libnettle, libnfs, libpixman, libpng, libspice-server, libssh, libusb, libusbredir, ncurses, pulseaudio, qemu-common, resolv-conf, zlib, zstd"
|
||||
TERMUX_PKG_SHA256=5b49ce2687744dad494ae90a898c52204a3406e84d072482a1e1be854eeb2157
|
||||
TERMUX_PKG_DEPENDS="glib, libbz2, libc++, libcurl, libgnutls, libiconv, libjpeg-turbo, liblzo, libnettle, libnfs, libpixman, libpng, libslirp, libspice-server, libssh, libusb, libusbredir, ncurses, pulseaudio, qemu-common, resolv-conf, zlib, zstd"
|
||||
|
||||
# Required by configuration script, but I can't find any binary that uses it.
|
||||
TERMUX_PKG_BUILD_DEPENDS="libtasn1"
|
||||
|
@ -16,6 +15,29 @@ TERMUX_PKG_REPLACES="qemu-system-x86_64-headless"
|
|||
TERMUX_PKG_PROVIDES="qemu-system-x86_64-headless"
|
||||
TERMUX_PKG_BUILD_IN_SRC=true
|
||||
|
||||
termux_step_pre_configure() {
|
||||
# Workaround for https://github.com/termux/termux-packages/issues/12261.
|
||||
if [ $TERMUX_ARCH = "aarch64" ]; then
|
||||
rm -f $TERMUX_PKG_BUILDDIR/_lib
|
||||
mkdir -p $TERMUX_PKG_BUILDDIR/_lib
|
||||
|
||||
cd $TERMUX_PKG_BUILDDIR
|
||||
mkdir -p _setjmp-aarch64
|
||||
pushd _setjmp-aarch64
|
||||
mkdir -p private
|
||||
local s
|
||||
for s in $TERMUX_PKG_BUILDER_DIR/setjmp-aarch64/{setjmp.S,private-*.h}; do
|
||||
local f=$(basename ${s})
|
||||
cp ${s} ./${f/-//}
|
||||
done
|
||||
$CC $CFLAGS $CPPFLAGS -I. setjmp.S -c
|
||||
$AR cru $TERMUX_PKG_BUILDDIR/_lib/libandroid-setjmp.a setjmp.o
|
||||
popd
|
||||
|
||||
LDFLAGS+=" -L$TERMUX_PKG_BUILDDIR/_lib -l:libandroid-setjmp.a"
|
||||
fi
|
||||
}
|
||||
|
||||
termux_step_configure() {
|
||||
termux_setup_ninja
|
||||
|
||||
|
@ -100,6 +122,7 @@ termux_step_configure() {
|
|||
--enable-dmg \
|
||||
--enable-parallels \
|
||||
--enable-qed \
|
||||
--enable-slirp \
|
||||
--enable-spice \
|
||||
--enable-libusb \
|
||||
--enable-usb-redir \
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
--- a/linux-user/syscall.c
|
||||
+++ b/linux-user/syscall.c
|
||||
@@ -102,7 +102,7 @@
|
||||
#include <linux/kd.h>
|
||||
#include <linux/mtio.h>
|
||||
|
||||
-#ifdef HAVE_SYS_MOUNT_FSCONFIG
|
||||
+#if defined HAVE_SYS_MOUNT_FSCONFIG && !defined __ANDROID__
|
||||
/*
|
||||
* glibc >= 2.36 linux/mount.h conflicts with sys/mount.h,
|
||||
* which in turn prevents use of linux/fs.h. So we have to
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* https://github.com/android/ndk/issues/1422 */
|
||||
#if 0
|
||||
#include <features.h>
|
||||
#endif
|
||||
|
||||
#include <asm/unistd.h> /* For system call numbers. */
|
||||
#define MAX_ERRNO 4095 /* For recognizing system call error returns. */
|
||||
|
||||
#define __bionic_asm_custom_entry(f)
|
||||
#define __bionic_asm_custom_end(f)
|
||||
#define __bionic_asm_function_type @function
|
||||
#define __bionic_asm_custom_note_gnu_section()
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#include <private/bionic_asm_arm64.h>
|
||||
#elif defined(__arm__)
|
||||
#include <private/bionic_asm_arm.h>
|
||||
#elif defined(__i386__)
|
||||
#include <private/bionic_asm_x86.h>
|
||||
#elif defined(__riscv)
|
||||
#include <private/bionic_asm_riscv64.h>
|
||||
#elif defined(__x86_64__)
|
||||
#include <private/bionic_asm_x86_64.h>
|
||||
#endif
|
||||
|
||||
#define ENTRY_NO_DWARF(f) \
|
||||
.text; \
|
||||
.globl f; \
|
||||
.balign __bionic_asm_align; \
|
||||
.type f, __bionic_asm_function_type; \
|
||||
f: \
|
||||
__bionic_asm_custom_entry(f); \
|
||||
|
||||
#define ENTRY(f) \
|
||||
ENTRY_NO_DWARF(f) \
|
||||
.cfi_startproc \
|
||||
|
||||
#define END_NO_DWARF(f) \
|
||||
.size f, .-f; \
|
||||
__bionic_asm_custom_end(f) \
|
||||
|
||||
#define END(f) \
|
||||
.cfi_endproc; \
|
||||
END_NO_DWARF(f) \
|
||||
|
||||
/* Like ENTRY, but with hidden visibility. */
|
||||
#define ENTRY_PRIVATE(f) \
|
||||
ENTRY(f); \
|
||||
.hidden f \
|
||||
|
||||
/* Like ENTRY_NO_DWARF, but with hidden visibility. */
|
||||
#define ENTRY_PRIVATE_NO_DWARF(f) \
|
||||
ENTRY_NO_DWARF(f); \
|
||||
.hidden f \
|
||||
|
||||
#define __BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(f) \
|
||||
.weak f; \
|
||||
|
||||
#define ALIAS_SYMBOL(alias, original) \
|
||||
.globl alias; \
|
||||
.equ alias, original
|
||||
|
||||
#define NOTE_GNU_PROPERTY() \
|
||||
__bionic_asm_custom_note_gnu_section()
|
|
@ -0,0 +1,79 @@
|
|||
/* $OpenBSD: asm.h,v 1.1 2004/02/01 05:09:49 drahn Exp $ */
|
||||
/* $NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)asm.h 5.5 (Berkeley) 5/7/91
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define __bionic_asm_align 16
|
||||
|
||||
#undef __bionic_asm_function_type
|
||||
#define __bionic_asm_function_type %function
|
||||
|
||||
#if defined(__ARM_FEATURE_BTI_DEFAULT)
|
||||
#define __bionic_asm_aarch64_feature_bti (1 << 0)
|
||||
#undef __bionic_asm_custom_entry
|
||||
#define __bionic_asm_custom_entry(f) bti c
|
||||
#else
|
||||
#define __bionic_asm_aarch64_feature_bti 0
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_FEATURE_PAC_DEFAULT)
|
||||
#define __bionic_asm_aarch64_feature_pac (1 << 1)
|
||||
#else
|
||||
#define __bionic_asm_aarch64_feature_pac 0
|
||||
#endif
|
||||
|
||||
#undef __bionic_asm_custom_note_gnu_section
|
||||
#define __bionic_asm_custom_note_gnu_section() \
|
||||
.pushsection .note.gnu.property, "a"; \
|
||||
.balign 8; \
|
||||
.long 4; \
|
||||
.long 0x10; \
|
||||
.long 0x5; /* NT_GNU_PROPERTY_TYPE_0 */ \
|
||||
.asciz "GNU"; \
|
||||
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ \
|
||||
.long 4; \
|
||||
.long (__bionic_asm_aarch64_feature_pac | \
|
||||
__bionic_asm_aarch64_feature_bti); \
|
||||
.long 0; \
|
||||
.popsection;
|
||||
|
||||
#define NT_MEMTAG_LEVEL_MASK 3
|
||||
#define NT_MEMTAG_LEVEL_NONE 0
|
||||
#define NT_MEMTAG_LEVEL_ASYNC 1
|
||||
#define NT_MEMTAG_LEVEL_SYNC 2
|
||||
#define NT_MEMTAG_HEAP 4
|
||||
#define NT_MEMTAG_STACK 8
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _BIONIC_CONSTANTS_H_
|
||||
#define _BIONIC_CONSTANTS_H_
|
||||
|
||||
#define NS_PER_S 1000000000
|
||||
|
||||
// Size of the shadow call stack. This must be a power of 2.
|
||||
#define SCS_SIZE (8 * 1024)
|
||||
|
||||
// The shadow call stack is allocated at an aligned address within a guard region of this size. The
|
||||
// guard region must be large enough that we can allocate an SCS_SIZE-aligned SCS while ensuring
|
||||
// that there is at least one guard page after the SCS so that a stack overflow results in a SIGSEGV
|
||||
// instead of corrupting the allocation that comes after it.
|
||||
#define SCS_GUARD_REGION_SIZE (16 * 1024 * 1024)
|
||||
|
||||
#endif // _BIONIC_CONSTANTS_H_
|
|
@ -0,0 +1,295 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
#include <private/bionic_constants.h>
|
||||
|
||||
// According to AARCH64 PCS document we need to save the following
|
||||
// registers:
|
||||
//
|
||||
// Core x19 - x30, sp (see section 5.1.1)
|
||||
// VFP d8 - d15 (see section 5.1.2)
|
||||
//
|
||||
// NOTE: All the registers saved here will have 64 bit vales.
|
||||
// AAPCS mandates that the higher part of q registers do not need to
|
||||
// be saved by the callee.
|
||||
//
|
||||
// The internal structure of a jmp_buf is totally private.
|
||||
// Current layout (changes from release to release):
|
||||
//
|
||||
// word name description
|
||||
// 0 sigflag/cookie setjmp cookie in top 31 bits, signal mask flag in low bit
|
||||
// 1 sigmask signal mask (not used with _setjmp / _longjmp)
|
||||
// 2 core_base base of core registers (x18-x30, sp)
|
||||
// (We only store the low bits of x18 to avoid leaking the
|
||||
// shadow call stack address into memory.)
|
||||
// 16 float_base base of float registers (d8-d15)
|
||||
// 24 checksum checksum of core registers
|
||||
// 25 reserved reserved entries (room to grow)
|
||||
// 32
|
||||
|
||||
#define _JB_SIGFLAG 0
|
||||
#define _JB_SIGMASK (_JB_SIGFLAG + 1)
|
||||
#define _JB_X30_SP (_JB_SIGMASK + 1)
|
||||
#define _JB_X28_X29 (_JB_X30_SP + 2)
|
||||
#define _JB_X26_X27 (_JB_X28_X29 + 2)
|
||||
#define _JB_X24_X25 (_JB_X26_X27 + 2)
|
||||
#define _JB_X22_X23 (_JB_X24_X25 + 2)
|
||||
#define _JB_X20_X21 (_JB_X22_X23 + 2)
|
||||
#define _JB_SCS_X19 (_JB_X20_X21 + 2)
|
||||
#define _JB_D14_D15 (_JB_SCS_X19 + 2)
|
||||
#define _JB_D12_D13 (_JB_D14_D15 + 2)
|
||||
#define _JB_D10_D11 (_JB_D12_D13 + 2)
|
||||
#define _JB_D8_D9 (_JB_D10_D11 + 2)
|
||||
#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
|
||||
eor x21, x21, \reg
|
||||
eor x22, x22, \reg
|
||||
eor x23, x23, \reg
|
||||
eor x24, x24, \reg
|
||||
eor x25, x25, \reg
|
||||
eor x26, x26, \reg
|
||||
eor x27, x27, \reg
|
||||
eor x28, x28, \reg
|
||||
eor x29, x29, \reg
|
||||
eor x30, x30, \reg
|
||||
eor \sp_reg, \sp_reg, \reg
|
||||
#endif
|
||||
.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
|
||||
ldr \scratch, [\src, #(\i * 8)]
|
||||
eor \dst, \dst, \scratch
|
||||
.endr
|
||||
.endm
|
||||
|
||||
.macro m_unmangle_registers reg, sp_reg
|
||||
m_mangle_registers \reg, sp_reg=\sp_reg
|
||||
.endm
|
||||
|
||||
ENTRY_PRIVATE(setjmp)
|
||||
mov w1, #1
|
||||
b sigsetjmp
|
||||
END(setjmp)
|
||||
|
||||
ENTRY_PRIVATE(_setjmp)
|
||||
mov w1, #0
|
||||
b sigsetjmp
|
||||
END(_setjmp)
|
||||
|
||||
// int sigsetjmp(sigjmp_buf env, int save_signal_mask);
|
||||
ENTRY_PRIVATE(sigsetjmp)
|
||||
stp x0, x30, [sp, #-16]!
|
||||
.cfi_def_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x30, 8
|
||||
|
||||
// Get the cookie and store it along with the signal flag.
|
||||
mov x0, x1
|
||||
//bl __bionic_setjmp_cookie_get
|
||||
mov x1, x0
|
||||
ldr x0, [sp, #0]
|
||||
str x1, [x0, #(_JB_SIGFLAG * 8)]
|
||||
|
||||
// Do we need to save the signal mask?
|
||||
tbz w1, #0, 1f
|
||||
|
||||
// Save the cookie for later.
|
||||
stp x1, xzr, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
|
||||
// Save current signal mask.
|
||||
// The 'how' argument is ignored if new_mask is NULL.
|
||||
mov x1, #0 // NULL.
|
||||
add x2, x0, #(_JB_SIGMASK * 8) // old_mask.
|
||||
bl sigprocmask
|
||||
|
||||
ldp x1, xzr, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
|
||||
1:
|
||||
// Restore original x0 and lr.
|
||||
ldp x0, x30, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x30
|
||||
|
||||
// Mask off the signal flag bit.
|
||||
bic x1, x1, #1
|
||||
|
||||
// Mask off the high bits of the shadow call stack pointer.
|
||||
and x3, x18, #SCS_MASK
|
||||
|
||||
// Save core registers.
|
||||
mov x10, sp
|
||||
m_mangle_registers x1, sp_reg=x10
|
||||
stp x30, x10, [x0, #(_JB_X30_SP * 8)]
|
||||
stp x28, x29, [x0, #(_JB_X28_X29 * 8)]
|
||||
stp x26, x27, [x0, #(_JB_X26_X27 * 8)]
|
||||
stp x24, x25, [x0, #(_JB_X24_X25 * 8)]
|
||||
stp x22, x23, [x0, #(_JB_X22_X23 * 8)]
|
||||
stp x20, x21, [x0, #(_JB_X20_X21 * 8)]
|
||||
stp x3, x19, [x0, #(_JB_SCS_X19 * 8)]
|
||||
m_unmangle_registers x1, sp_reg=x10
|
||||
|
||||
// Save floating point registers.
|
||||
stp d14, d15, [x0, #(_JB_D14_D15 * 8)]
|
||||
stp d12, d13, [x0, #(_JB_D12_D13 * 8)]
|
||||
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
|
||||
ret
|
||||
END(sigsetjmp)
|
||||
|
||||
// void siglongjmp(sigjmp_buf env, int value);
|
||||
ENTRY_PRIVATE(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]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x30, 8
|
||||
mov x19, x1 // Save 'value'.
|
||||
|
||||
// load and unmangle destination SP
|
||||
ldr x2, [x0, #(_JB_SIGFLAG * 8)]
|
||||
bic x2, x2, #1
|
||||
ldr x0, [x0, #(_JB_X30_SP * 8 + 8)]
|
||||
eor x0, x0, x2
|
||||
bl __hwasan_handle_longjmp
|
||||
|
||||
mov x1, x19 // Restore 'value'.
|
||||
// Restore original x0 and lr.
|
||||
ldp x0, x30, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x30
|
||||
#endif
|
||||
|
||||
// Do we need to restore the signal mask?
|
||||
ldr x2, [x0, #(_JB_SIGFLAG * 8)]
|
||||
tbz w2, #0, 1f
|
||||
|
||||
stp x0, x30, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x30, 8
|
||||
|
||||
// Restore signal mask.
|
||||
mov x19, x1 // Save 'value'.
|
||||
|
||||
mov x2, x0
|
||||
mov x0, #2 // SIG_SETMASK
|
||||
add x1, x2, #(_JB_SIGMASK * 8) // new_mask.
|
||||
mov x2, #0 // NULL.
|
||||
bl sigprocmask
|
||||
mov x1, x19 // Restore 'value'.
|
||||
|
||||
// Restore original x0 and lr.
|
||||
ldp x0, x30, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x30
|
||||
|
||||
ldr x2, [x0, #(_JB_SIGFLAG * 8)]
|
||||
1:
|
||||
// Restore core registers.
|
||||
bic x2, x2, #1
|
||||
ldp x30, x10, [x0, #(_JB_X30_SP * 8)]
|
||||
ldp x28, x29, [x0, #(_JB_X28_X29 * 8)]
|
||||
ldp x26, x27, [x0, #(_JB_X26_X27 * 8)]
|
||||
ldp x24, x25, [x0, #(_JB_X24_X25 * 8)]
|
||||
ldp x22, x23, [x0, #(_JB_X22_X23 * 8)]
|
||||
ldp x20, x21, [x0, #(_JB_X20_X21 * 8)]
|
||||
ldp x3, x19, [x0, #(_JB_SCS_X19 * 8)]
|
||||
m_unmangle_registers x2, sp_reg=x10
|
||||
mov sp, x10
|
||||
|
||||
// Restore the low bits of the shadow call stack pointer.
|
||||
and x18, x18, #~SCS_MASK
|
||||
orr x18, x3, x18
|
||||
|
||||
stp x0, x1, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x1, 8
|
||||
stp x30, xzr, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x30, 0
|
||||
ldr x0, [x0, #(_JB_SIGFLAG * 8)]
|
||||
//bl __bionic_setjmp_cookie_check
|
||||
ldp x30, xzr, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x30
|
||||
ldp x0, x1, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x1
|
||||
|
||||
// Restore floating point registers.
|
||||
ldp d14, d15, [x0, #(_JB_D14_D15 * 8)]
|
||||
ldp d12, d13, [x0, #(_JB_D12_D13 * 8)]
|
||||
ldp d10, d11, [x0, #(_JB_D10_D11 * 8)]
|
||||
ldp d8, d9, [x0, #(_JB_D8_D9 * 8)]
|
||||
|
||||
// Set return value.
|
||||
cmp w1, wzr
|
||||
csinc w0, w1, wzr, ne
|
||||
ret
|
||||
END(siglongjmp)
|
||||
|
||||
ALIAS_SYMBOL(longjmp, siglongjmp)
|
||||
.hidden longjmp
|
||||
ALIAS_SYMBOL(_longjmp, siglongjmp)
|
||||
.hidden _longjmp
|
|
@ -2,14 +2,14 @@ diff -uNr qemu-6.1.0/block.c qemu-6.1.0.mod/block.c
|
|||
--- qemu-6.1.0/block.c 2021-08-24 20:35:40.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/block.c 2021-08-25 15:22:26.469952602 +0300
|
||||
@@ -833,7 +833,7 @@
|
||||
const char *tmpdir;
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) {
|
||||
* /var/tmp is usually on a disk, so more appropriate for disk images.
|
||||
*/
|
||||
if (!g_strcmp0(tmpdir, "/tmp")) {
|
||||
- tmpdir = "/var/tmp";
|
||||
+ tmpdir = "@TERMUX_PREFIX@/tmp";
|
||||
}
|
||||
if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) {
|
||||
return -EOVERFLOW;
|
||||
#endif
|
||||
|
||||
diff -uNr qemu-6.1.0/hw/hppa/machine.c qemu-6.1.0.mod/hw/hppa/machine.c
|
||||
--- qemu-6.1.0/hw/hppa/machine.c 2021-08-24 20:35:40.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/hw/hppa/machine.c 2021-08-25 15:22:26.469952602 +0300
|
||||
|
@ -122,31 +122,6 @@ diff -uNr qemu-6.1.0/qemu-nbd.c qemu-6.1.0.mod/qemu-nbd.c
|
|||
}
|
||||
|
||||
server = qio_net_listener_new();
|
||||
diff -uNr qemu-6.1.0/slirp/src/slirp.c qemu-6.1.0.mod/slirp/src/slirp.c
|
||||
--- qemu-6.1.0/slirp/src/slirp.c 2021-08-24 20:36:28.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/slirp/src/slirp.c 2021-08-25 15:23:17.110356661 +0300
|
||||
@@ -221,7 +221,7 @@
|
||||
#if defined(__HAIKU__)
|
||||
#define RESOLV_CONF_PATH "/boot/system/settings/network/resolv.conf"
|
||||
#else
|
||||
-#define RESOLV_CONF_PATH "/etc/resolv.conf"
|
||||
+#define RESOLV_CONF_PATH "@TERMUX_PREFIX@/etc/resolv.conf"
|
||||
#endif
|
||||
|
||||
static int get_dns_addr_cached(void *pdns_addr, void *cached_addr,
|
||||
diff -uNr qemu-6.1.0/tcg/tcg.c qemu-6.1.0.mod/tcg/tcg.c
|
||||
--- qemu-6.1.0/tcg/tcg.c 2021-08-24 20:35:41.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/tcg/tcg.c 2021-08-25 15:22:26.485952693 +0300
|
||||
@@ -4684,7 +4684,8 @@
|
||||
/* Enable this block to be able to debug the ELF image file creation.
|
||||
One can use readelf, objdump, or other inspection utilities. */
|
||||
{
|
||||
- FILE *f = fopen("/tmp/qemu.jit", "w+b");
|
||||
+ FILE *f = fopen("@TERMUX_PREFIX@/tmp/qemu.jit", "w+b");
|
||||
+
|
||||
if (f) {
|
||||
if (fwrite(img, img_size, 1, f) != img_size) {
|
||||
/* Avoid stupid unused return value warning for fwrite. */
|
||||
diff -uNr qemu-6.1.0/util/module.c qemu-6.1.0.mod/util/module.c
|
||||
--- qemu-6.1.0/util/module.c 2021-08-24 20:35:41.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/util/module.c 2021-08-25 15:22:26.485952693 +0300
|
||||
|
@ -159,15 +134,3 @@ diff -uNr qemu-6.1.0/util/module.c qemu-6.1.0.mod/util/module.c
|
|||
#endif
|
||||
|
||||
assert(n_dirs <= ARRAY_SIZE(dirs));
|
||||
diff -uNr qemu-6.1.0/util/qemu-sockets.c qemu-6.1.0.mod/util/qemu-sockets.c
|
||||
--- qemu-6.1.0/util/qemu-sockets.c 2021-08-24 20:35:41.000000000 +0300
|
||||
+++ qemu-6.1.0.mod/util/qemu-sockets.c 2021-08-25 15:22:26.485952693 +0300
|
||||
@@ -923,7 +923,7 @@
|
||||
path = saddr->path;
|
||||
} else {
|
||||
const char *tmpdir = getenv("TMPDIR");
|
||||
- tmpdir = tmpdir ? tmpdir : "/tmp";
|
||||
+ tmpdir = tmpdir ? tmpdir : "@TERMUX_PREFIX@/tmp";
|
||||
path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ diff -uNr qemu-6.1.0/meson.build qemu-6.1.0.mod/meson.build
|
|||
--- qemu-6.1.0/meson.build 2021-08-25 21:20:39.873631512 +0300
|
||||
+++ qemu-6.1.0.mod/meson.build 2021-08-25 21:21:35.135670419 +0300
|
||||
@@ -1785,10 +1785,6 @@
|
||||
CPU_FREE(cpuset);
|
||||
return 0;
|
||||
}''', dependencies: threads))
|
||||
|
||||
-config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
|
||||
- #include <sys/signalfd.h>
|
||||
- #include <stddef.h>
|
||||
|
|
|
@ -2,11 +2,10 @@ TERMUX_PKG_HOMEPAGE=https://www.qemu.org
|
|||
TERMUX_PKG_DESCRIPTION="A generic and open source machine emulator and virtualizer"
|
||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=1:7.1.0
|
||||
TERMUX_PKG_REVISION=1
|
||||
TERMUX_PKG_VERSION=1:7.2.0
|
||||
TERMUX_PKG_SRCURL=https://download.qemu.org/qemu-${TERMUX_PKG_VERSION:2}.tar.xz
|
||||
TERMUX_PKG_SHA256=a0634e536bded57cf38ec8a751adb124b89c776fe0846f21ab6c6728f1cbbbe6
|
||||
TERMUX_PKG_DEPENDS="glib, gtk3, libbz2, libc++, libcurl, libgnutls, libiconv, libjpeg-turbo, liblzo, libnettle, libnfs, libpixman, libpng, libspice-server, libssh, libusb, libusbredir, libx11, ncurses, pulseaudio, qemu-common, resolv-conf, sdl2, sdl2-image, zlib, zstd"
|
||||
TERMUX_PKG_SHA256=5b49ce2687744dad494ae90a898c52204a3406e84d072482a1e1be854eeb2157
|
||||
TERMUX_PKG_DEPENDS="glib, gtk3, libbz2, libc++, libcurl, libgnutls, libiconv, libjpeg-turbo, liblzo, libnettle, libnfs, libpixman, libpng, libslirp, libspice-server, libssh, libusb, libusbredir, libx11, ncurses, pulseaudio, qemu-common, resolv-conf, sdl2, sdl2-image, zlib, zstd"
|
||||
|
||||
# Required by configuration script, but I can't find any binary that uses it.
|
||||
TERMUX_PKG_BUILD_DEPENDS="libtasn1"
|
||||
|
@ -42,6 +41,29 @@ TERMUX_PKG_REPLACES="qemu-system-x86_64, qemu-system-x86_64-headless, qemu-syste
|
|||
TERMUX_PKG_PROVIDES="qemu-system-x86_64"
|
||||
TERMUX_PKG_BUILD_IN_SRC=true
|
||||
|
||||
termux_step_pre_configure() {
|
||||
# Workaround for https://github.com/termux/termux-packages/issues/12261.
|
||||
if [ $TERMUX_ARCH = "aarch64" ]; then
|
||||
rm -f $TERMUX_PKG_BUILDDIR/_lib
|
||||
mkdir -p $TERMUX_PKG_BUILDDIR/_lib
|
||||
|
||||
cd $TERMUX_PKG_BUILDDIR
|
||||
mkdir -p _setjmp-aarch64
|
||||
pushd _setjmp-aarch64
|
||||
mkdir -p private
|
||||
local s
|
||||
for s in $TERMUX_PKG_BUILDER_DIR/setjmp-aarch64/{setjmp.S,private-*.h}; do
|
||||
local f=$(basename ${s})
|
||||
cp ${s} ./${f/-//}
|
||||
done
|
||||
$CC $CFLAGS $CPPFLAGS -I. setjmp.S -c
|
||||
$AR cru $TERMUX_PKG_BUILDDIR/_lib/libandroid-setjmp.a setjmp.o
|
||||
popd
|
||||
|
||||
LDFLAGS+=" -L$TERMUX_PKG_BUILDDIR/_lib -l:libandroid-setjmp.a"
|
||||
fi
|
||||
}
|
||||
|
||||
termux_step_configure() {
|
||||
termux_setup_ninja
|
||||
|
||||
|
@ -115,6 +137,7 @@ termux_step_configure() {
|
|||
--enable-dmg \
|
||||
--enable-parallels \
|
||||
--enable-qed \
|
||||
--enable-slirp \
|
||||
--enable-spice \
|
||||
--enable-libusb \
|
||||
--enable-usb-redir \
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
--- a/linux-user/syscall.c
|
||||
+++ b/linux-user/syscall.c
|
||||
@@ -102,7 +102,7 @@
|
||||
#include <linux/kd.h>
|
||||
#include <linux/mtio.h>
|
||||
|
||||
-#ifdef HAVE_SYS_MOUNT_FSCONFIG
|
||||
+#if defined HAVE_SYS_MOUNT_FSCONFIG && !defined __ANDROID__
|
||||
/*
|
||||
* glibc >= 2.36 linux/mount.h conflicts with sys/mount.h,
|
||||
* which in turn prevents use of linux/fs.h. So we have to
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* https://github.com/android/ndk/issues/1422 */
|
||||
#if 0
|
||||
#include <features.h>
|
||||
#endif
|
||||
|
||||
#include <asm/unistd.h> /* For system call numbers. */
|
||||
#define MAX_ERRNO 4095 /* For recognizing system call error returns. */
|
||||
|
||||
#define __bionic_asm_custom_entry(f)
|
||||
#define __bionic_asm_custom_end(f)
|
||||
#define __bionic_asm_function_type @function
|
||||
#define __bionic_asm_custom_note_gnu_section()
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#include <private/bionic_asm_arm64.h>
|
||||
#elif defined(__arm__)
|
||||
#include <private/bionic_asm_arm.h>
|
||||
#elif defined(__i386__)
|
||||
#include <private/bionic_asm_x86.h>
|
||||
#elif defined(__riscv)
|
||||
#include <private/bionic_asm_riscv64.h>
|
||||
#elif defined(__x86_64__)
|
||||
#include <private/bionic_asm_x86_64.h>
|
||||
#endif
|
||||
|
||||
#define ENTRY_NO_DWARF(f) \
|
||||
.text; \
|
||||
.globl f; \
|
||||
.balign __bionic_asm_align; \
|
||||
.type f, __bionic_asm_function_type; \
|
||||
f: \
|
||||
__bionic_asm_custom_entry(f); \
|
||||
|
||||
#define ENTRY(f) \
|
||||
ENTRY_NO_DWARF(f) \
|
||||
.cfi_startproc \
|
||||
|
||||
#define END_NO_DWARF(f) \
|
||||
.size f, .-f; \
|
||||
__bionic_asm_custom_end(f) \
|
||||
|
||||
#define END(f) \
|
||||
.cfi_endproc; \
|
||||
END_NO_DWARF(f) \
|
||||
|
||||
/* Like ENTRY, but with hidden visibility. */
|
||||
#define ENTRY_PRIVATE(f) \
|
||||
ENTRY(f); \
|
||||
.hidden f \
|
||||
|
||||
/* Like ENTRY_NO_DWARF, but with hidden visibility. */
|
||||
#define ENTRY_PRIVATE_NO_DWARF(f) \
|
||||
ENTRY_NO_DWARF(f); \
|
||||
.hidden f \
|
||||
|
||||
#define __BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(f) \
|
||||
.weak f; \
|
||||
|
||||
#define ALIAS_SYMBOL(alias, original) \
|
||||
.globl alias; \
|
||||
.equ alias, original
|
||||
|
||||
#define NOTE_GNU_PROPERTY() \
|
||||
__bionic_asm_custom_note_gnu_section()
|
|
@ -0,0 +1,79 @@
|
|||
/* $OpenBSD: asm.h,v 1.1 2004/02/01 05:09:49 drahn Exp $ */
|
||||
/* $NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)asm.h 5.5 (Berkeley) 5/7/91
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define __bionic_asm_align 16
|
||||
|
||||
#undef __bionic_asm_function_type
|
||||
#define __bionic_asm_function_type %function
|
||||
|
||||
#if defined(__ARM_FEATURE_BTI_DEFAULT)
|
||||
#define __bionic_asm_aarch64_feature_bti (1 << 0)
|
||||
#undef __bionic_asm_custom_entry
|
||||
#define __bionic_asm_custom_entry(f) bti c
|
||||
#else
|
||||
#define __bionic_asm_aarch64_feature_bti 0
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_FEATURE_PAC_DEFAULT)
|
||||
#define __bionic_asm_aarch64_feature_pac (1 << 1)
|
||||
#else
|
||||
#define __bionic_asm_aarch64_feature_pac 0
|
||||
#endif
|
||||
|
||||
#undef __bionic_asm_custom_note_gnu_section
|
||||
#define __bionic_asm_custom_note_gnu_section() \
|
||||
.pushsection .note.gnu.property, "a"; \
|
||||
.balign 8; \
|
||||
.long 4; \
|
||||
.long 0x10; \
|
||||
.long 0x5; /* NT_GNU_PROPERTY_TYPE_0 */ \
|
||||
.asciz "GNU"; \
|
||||
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ \
|
||||
.long 4; \
|
||||
.long (__bionic_asm_aarch64_feature_pac | \
|
||||
__bionic_asm_aarch64_feature_bti); \
|
||||
.long 0; \
|
||||
.popsection;
|
||||
|
||||
#define NT_MEMTAG_LEVEL_MASK 3
|
||||
#define NT_MEMTAG_LEVEL_NONE 0
|
||||
#define NT_MEMTAG_LEVEL_ASYNC 1
|
||||
#define NT_MEMTAG_LEVEL_SYNC 2
|
||||
#define NT_MEMTAG_HEAP 4
|
||||
#define NT_MEMTAG_STACK 8
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _BIONIC_CONSTANTS_H_
|
||||
#define _BIONIC_CONSTANTS_H_
|
||||
|
||||
#define NS_PER_S 1000000000
|
||||
|
||||
// Size of the shadow call stack. This must be a power of 2.
|
||||
#define SCS_SIZE (8 * 1024)
|
||||
|
||||
// The shadow call stack is allocated at an aligned address within a guard region of this size. The
|
||||
// guard region must be large enough that we can allocate an SCS_SIZE-aligned SCS while ensuring
|
||||
// that there is at least one guard page after the SCS so that a stack overflow results in a SIGSEGV
|
||||
// instead of corrupting the allocation that comes after it.
|
||||
#define SCS_GUARD_REGION_SIZE (16 * 1024 * 1024)
|
||||
|
||||
#endif // _BIONIC_CONSTANTS_H_
|
|
@ -0,0 +1,295 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
#include <private/bionic_constants.h>
|
||||
|
||||
// According to AARCH64 PCS document we need to save the following
|
||||
// registers:
|
||||
//
|
||||
// Core x19 - x30, sp (see section 5.1.1)
|
||||
// VFP d8 - d15 (see section 5.1.2)
|
||||
//
|
||||
// NOTE: All the registers saved here will have 64 bit vales.
|
||||
// AAPCS mandates that the higher part of q registers do not need to
|
||||
// be saved by the callee.
|
||||
//
|
||||
// The internal structure of a jmp_buf is totally private.
|
||||
// Current layout (changes from release to release):
|
||||
//
|
||||
// word name description
|
||||
// 0 sigflag/cookie setjmp cookie in top 31 bits, signal mask flag in low bit
|
||||
// 1 sigmask signal mask (not used with _setjmp / _longjmp)
|
||||
// 2 core_base base of core registers (x18-x30, sp)
|
||||
// (We only store the low bits of x18 to avoid leaking the
|
||||
// shadow call stack address into memory.)
|
||||
// 16 float_base base of float registers (d8-d15)
|
||||
// 24 checksum checksum of core registers
|
||||
// 25 reserved reserved entries (room to grow)
|
||||
// 32
|
||||
|
||||
#define _JB_SIGFLAG 0
|
||||
#define _JB_SIGMASK (_JB_SIGFLAG + 1)
|
||||
#define _JB_X30_SP (_JB_SIGMASK + 1)
|
||||
#define _JB_X28_X29 (_JB_X30_SP + 2)
|
||||
#define _JB_X26_X27 (_JB_X28_X29 + 2)
|
||||
#define _JB_X24_X25 (_JB_X26_X27 + 2)
|
||||
#define _JB_X22_X23 (_JB_X24_X25 + 2)
|
||||
#define _JB_X20_X21 (_JB_X22_X23 + 2)
|
||||
#define _JB_SCS_X19 (_JB_X20_X21 + 2)
|
||||
#define _JB_D14_D15 (_JB_SCS_X19 + 2)
|
||||
#define _JB_D12_D13 (_JB_D14_D15 + 2)
|
||||
#define _JB_D10_D11 (_JB_D12_D13 + 2)
|
||||
#define _JB_D8_D9 (_JB_D10_D11 + 2)
|
||||
#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
|
||||
eor x21, x21, \reg
|
||||
eor x22, x22, \reg
|
||||
eor x23, x23, \reg
|
||||
eor x24, x24, \reg
|
||||
eor x25, x25, \reg
|
||||
eor x26, x26, \reg
|
||||
eor x27, x27, \reg
|
||||
eor x28, x28, \reg
|
||||
eor x29, x29, \reg
|
||||
eor x30, x30, \reg
|
||||
eor \sp_reg, \sp_reg, \reg
|
||||
#endif
|
||||
.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
|
||||
ldr \scratch, [\src, #(\i * 8)]
|
||||
eor \dst, \dst, \scratch
|
||||
.endr
|
||||
.endm
|
||||
|
||||
.macro m_unmangle_registers reg, sp_reg
|
||||
m_mangle_registers \reg, sp_reg=\sp_reg
|
||||
.endm
|
||||
|
||||
ENTRY_PRIVATE(setjmp)
|
||||
mov w1, #1
|
||||
b sigsetjmp
|
||||
END(setjmp)
|
||||
|
||||
ENTRY_PRIVATE(_setjmp)
|
||||
mov w1, #0
|
||||
b sigsetjmp
|
||||
END(_setjmp)
|
||||
|
||||
// int sigsetjmp(sigjmp_buf env, int save_signal_mask);
|
||||
ENTRY_PRIVATE(sigsetjmp)
|
||||
stp x0, x30, [sp, #-16]!
|
||||
.cfi_def_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x30, 8
|
||||
|
||||
// Get the cookie and store it along with the signal flag.
|
||||
mov x0, x1
|
||||
//bl __bionic_setjmp_cookie_get
|
||||
mov x1, x0
|
||||
ldr x0, [sp, #0]
|
||||
str x1, [x0, #(_JB_SIGFLAG * 8)]
|
||||
|
||||
// Do we need to save the signal mask?
|
||||
tbz w1, #0, 1f
|
||||
|
||||
// Save the cookie for later.
|
||||
stp x1, xzr, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
|
||||
// Save current signal mask.
|
||||
// The 'how' argument is ignored if new_mask is NULL.
|
||||
mov x1, #0 // NULL.
|
||||
add x2, x0, #(_JB_SIGMASK * 8) // old_mask.
|
||||
bl sigprocmask
|
||||
|
||||
ldp x1, xzr, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
|
||||
1:
|
||||
// Restore original x0 and lr.
|
||||
ldp x0, x30, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x30
|
||||
|
||||
// Mask off the signal flag bit.
|
||||
bic x1, x1, #1
|
||||
|
||||
// Mask off the high bits of the shadow call stack pointer.
|
||||
and x3, x18, #SCS_MASK
|
||||
|
||||
// Save core registers.
|
||||
mov x10, sp
|
||||
m_mangle_registers x1, sp_reg=x10
|
||||
stp x30, x10, [x0, #(_JB_X30_SP * 8)]
|
||||
stp x28, x29, [x0, #(_JB_X28_X29 * 8)]
|
||||
stp x26, x27, [x0, #(_JB_X26_X27 * 8)]
|
||||
stp x24, x25, [x0, #(_JB_X24_X25 * 8)]
|
||||
stp x22, x23, [x0, #(_JB_X22_X23 * 8)]
|
||||
stp x20, x21, [x0, #(_JB_X20_X21 * 8)]
|
||||
stp x3, x19, [x0, #(_JB_SCS_X19 * 8)]
|
||||
m_unmangle_registers x1, sp_reg=x10
|
||||
|
||||
// Save floating point registers.
|
||||
stp d14, d15, [x0, #(_JB_D14_D15 * 8)]
|
||||
stp d12, d13, [x0, #(_JB_D12_D13 * 8)]
|
||||
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
|
||||
ret
|
||||
END(sigsetjmp)
|
||||
|
||||
// void siglongjmp(sigjmp_buf env, int value);
|
||||
ENTRY_PRIVATE(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]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x30, 8
|
||||
mov x19, x1 // Save 'value'.
|
||||
|
||||
// load and unmangle destination SP
|
||||
ldr x2, [x0, #(_JB_SIGFLAG * 8)]
|
||||
bic x2, x2, #1
|
||||
ldr x0, [x0, #(_JB_X30_SP * 8 + 8)]
|
||||
eor x0, x0, x2
|
||||
bl __hwasan_handle_longjmp
|
||||
|
||||
mov x1, x19 // Restore 'value'.
|
||||
// Restore original x0 and lr.
|
||||
ldp x0, x30, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x30
|
||||
#endif
|
||||
|
||||
// Do we need to restore the signal mask?
|
||||
ldr x2, [x0, #(_JB_SIGFLAG * 8)]
|
||||
tbz w2, #0, 1f
|
||||
|
||||
stp x0, x30, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x30, 8
|
||||
|
||||
// Restore signal mask.
|
||||
mov x19, x1 // Save 'value'.
|
||||
|
||||
mov x2, x0
|
||||
mov x0, #2 // SIG_SETMASK
|
||||
add x1, x2, #(_JB_SIGMASK * 8) // new_mask.
|
||||
mov x2, #0 // NULL.
|
||||
bl sigprocmask
|
||||
mov x1, x19 // Restore 'value'.
|
||||
|
||||
// Restore original x0 and lr.
|
||||
ldp x0, x30, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x30
|
||||
|
||||
ldr x2, [x0, #(_JB_SIGFLAG * 8)]
|
||||
1:
|
||||
// Restore core registers.
|
||||
bic x2, x2, #1
|
||||
ldp x30, x10, [x0, #(_JB_X30_SP * 8)]
|
||||
ldp x28, x29, [x0, #(_JB_X28_X29 * 8)]
|
||||
ldp x26, x27, [x0, #(_JB_X26_X27 * 8)]
|
||||
ldp x24, x25, [x0, #(_JB_X24_X25 * 8)]
|
||||
ldp x22, x23, [x0, #(_JB_X22_X23 * 8)]
|
||||
ldp x20, x21, [x0, #(_JB_X20_X21 * 8)]
|
||||
ldp x3, x19, [x0, #(_JB_SCS_X19 * 8)]
|
||||
m_unmangle_registers x2, sp_reg=x10
|
||||
mov sp, x10
|
||||
|
||||
// Restore the low bits of the shadow call stack pointer.
|
||||
and x18, x18, #~SCS_MASK
|
||||
orr x18, x3, x18
|
||||
|
||||
stp x0, x1, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x0, 0
|
||||
.cfi_rel_offset x1, 8
|
||||
stp x30, xzr, [sp, #-16]!
|
||||
.cfi_adjust_cfa_offset 16
|
||||
.cfi_rel_offset x30, 0
|
||||
ldr x0, [x0, #(_JB_SIGFLAG * 8)]
|
||||
//bl __bionic_setjmp_cookie_check
|
||||
ldp x30, xzr, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x30
|
||||
ldp x0, x1, [sp], #16
|
||||
.cfi_adjust_cfa_offset -16
|
||||
.cfi_restore x0
|
||||
.cfi_restore x1
|
||||
|
||||
// Restore floating point registers.
|
||||
ldp d14, d15, [x0, #(_JB_D14_D15 * 8)]
|
||||
ldp d12, d13, [x0, #(_JB_D12_D13 * 8)]
|
||||
ldp d10, d11, [x0, #(_JB_D10_D11 * 8)]
|
||||
ldp d8, d9, [x0, #(_JB_D8_D9 * 8)]
|
||||
|
||||
// Set return value.
|
||||
cmp w1, wzr
|
||||
csinc w0, w1, wzr, ne
|
||||
ret
|
||||
END(siglongjmp)
|
||||
|
||||
ALIAS_SYMBOL(longjmp, siglongjmp)
|
||||
.hidden longjmp
|
||||
ALIAS_SYMBOL(_longjmp, siglongjmp)
|
||||
.hidden _longjmp
|
Loading…
Reference in New Issue