summaryrefslogtreecommitdiffstats
path: root/qemu/bsd-user
diff options
context:
space:
mode:
authorJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:18:31 +0300
committerJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:42:15 +0300
commit437fd90c0250dee670290f9b714253671a990160 (patch)
treeb871786c360704244a07411c69fb58da9ead4a06 /qemu/bsd-user
parent5bbd6fe9b8bab2a93e548c5a53b032d1939eec05 (diff)
These changes are the raw update to qemu-2.6.
Collission happened in the following patches: migration: do cleanup operation after completion(738df5b9) Bug fix.(1750c932f86) kvmclock: add a new function to update env->tsc.(b52baab2) The code provided by the patches was already in the upstreamed version. Change-Id: I3cc11841a6a76ae20887b2e245710199e1ea7f9a Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'qemu/bsd-user')
-rw-r--r--qemu/bsd-user/bsdload.c8
-rw-r--r--qemu/bsd-user/elfload.c18
-rw-r--r--qemu/bsd-user/i386/target_syscall.h (renamed from qemu/bsd-user/i386/syscall.h)4
-rw-r--r--qemu/bsd-user/main.c30
-rw-r--r--qemu/bsd-user/mmap.c7
-rw-r--r--qemu/bsd-user/qemu.h9
-rw-r--r--qemu/bsd-user/signal.c10
-rw-r--r--qemu/bsd-user/sparc/target_syscall.h (renamed from qemu/bsd-user/sparc/syscall.h)5
-rw-r--r--qemu/bsd-user/sparc64/target_syscall.h (renamed from qemu/bsd-user/sparc64/syscall.h)5
-rw-r--r--qemu/bsd-user/strace.c6
-rw-r--r--qemu/bsd-user/syscall.c14
-rw-r--r--qemu/bsd-user/uaccess.c6
-rw-r--r--qemu/bsd-user/x86_64/target_syscall.h (renamed from qemu/bsd-user/x86_64/syscall.h)5
13 files changed, 41 insertions, 86 deletions
diff --git a/qemu/bsd-user/bsdload.c b/qemu/bsd-user/bsdload.c
index 2abc7136e..94eec363b 100644
--- a/qemu/bsd-user/bsdload.c
+++ b/qemu/bsd-user/bsdload.c
@@ -1,12 +1,6 @@
/* Code for loading BSD executables. Mostly linux kernel code. */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include "qemu/osdep.h"
#include "qemu.h"
diff --git a/qemu/bsd-user/elfload.c b/qemu/bsd-user/elfload.c
index 2bf57eb1f..898ee0547 100644
--- a/qemu/bsd-user/elfload.c
+++ b/qemu/bsd-user/elfload.c
@@ -1,16 +1,11 @@
/* This is the Linux kernel elf-loading code, ported into user space */
-#include <stdio.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
+#include "qemu/osdep.h"
#include <sys/mman.h>
-#include <stdlib.h>
-#include <string.h>
#include "qemu.h"
#include "disas/disas.h"
+#include "qemu/path.h"
#ifdef _ARCH_PPC64
#undef ARCH_DLINFO
@@ -740,8 +735,7 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_bss)
size must be known */
if (qemu_real_host_page_size < qemu_host_page_size) {
abi_ulong end_addr, end_addr1;
- end_addr1 = (elf_bss + qemu_real_host_page_size - 1) &
- ~(qemu_real_host_page_size - 1);
+ end_addr1 = REAL_HOST_PAGE_ALIGN(elf_bss);
end_addr = HOST_PAGE_ALIGN(elf_bss);
if (end_addr1 < end_addr) {
mmap((void *)g2h(end_addr1), end_addr - end_addr1,
@@ -1355,9 +1349,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
}
}
if (!bprm->p) {
- if (elf_interpreter) {
- free(elf_interpreter);
- }
+ free(elf_interpreter);
free (elf_phdata);
close(bprm->fd);
return -E2BIG;
@@ -1371,7 +1363,6 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
info->mmap = 0;
elf_entry = (abi_ulong) elf_ex.e_entry;
-#if defined(CONFIG_USE_GUEST_BASE)
/*
* In case where user has not explicitly set the guest_base, we
* probe here that should we set it automatically.
@@ -1392,7 +1383,6 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
}
}
}
-#endif /* CONFIG_USE_GUEST_BASE */
/* Do this so that we can load the interpreter, if need be. We will
change some of these later */
diff --git a/qemu/bsd-user/i386/syscall.h b/qemu/bsd-user/i386/target_syscall.h
index 9b34c61bb..82d1c58ca 100644
--- a/qemu/bsd-user/i386/syscall.h
+++ b/qemu/bsd-user/i386/target_syscall.h
@@ -1,3 +1,6 @@
+#ifndef TARGET_SYSCALL_H
+#define TARGET_SYSCALL_H
+
/* default linux values for the selectors */
#define __USER_CS (0x23)
#define __USER_DS (0x2B)
@@ -159,3 +162,4 @@ struct target_vm86plus_struct {
#define UNAME_MACHINE "i386"
+#endif /* TARGET_SYSCALL_H */
diff --git a/qemu/bsd-user/main.c b/qemu/bsd-user/main.c
index ee68daa39..27854c1f9 100644
--- a/qemu/bsd-user/main.c
+++ b/qemu/bsd-user/main.c
@@ -16,31 +16,25 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
+#include "qemu/osdep.h"
#include <machine/trap.h>
-#include <sys/types.h>
#include <sys/mman.h>
#include "qemu.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
+#include "qemu/help_option.h"
/* For tb_lock */
#include "cpu.h"
#include "tcg.h"
#include "qemu/timer.h"
#include "qemu/envlist.h"
+#include "exec/log.h"
int singlestep;
-#if defined(CONFIG_USE_GUEST_BASE)
unsigned long mmap_min_addr;
unsigned long guest_base;
int have_guest_base;
unsigned long reserved_va;
-#endif
static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
const char *qemu_uname_release;
@@ -110,7 +104,7 @@ void cpu_list_unlock(void)
uint64_t cpu_get_tsc(CPUX86State *env)
{
- return cpu_get_real_ticks();
+ return cpu_get_host_ticks();
}
static void write_dt(void *ptr, unsigned long addr, unsigned long limit,
@@ -682,9 +676,7 @@ static void usage(void)
"-drop-ld-preload drop LD_PRELOAD for target process\n"
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
-#if defined(CONFIG_USE_GUEST_BASE)
"-B address set guest_base address to address\n"
-#endif
"-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)\n"
"\n"
"Debug options:\n"
@@ -830,11 +822,9 @@ int main(int argc, char **argv)
#endif
exit(1);
}
-#if defined(CONFIG_USE_GUEST_BASE)
} else if (!strcmp(r, "B")) {
guest_base = strtol(argv[optind++], NULL, 0);
have_guest_base = 1;
-#endif
} else if (!strcmp(r, "drop-ld-preload")) {
(void) envlist_unsetenv(envlist, "LD_PRELOAD");
} else if (!strcmp(r, "bsd")) {
@@ -923,7 +913,6 @@ int main(int argc, char **argv)
target_environ = envlist_to_environ(envlist, NULL);
envlist_free(envlist);
-#if defined(CONFIG_USE_GUEST_BASE)
/*
* Now that page sizes are configured in cpu_init() we can do
* proper page alignment for guest_base.
@@ -945,12 +934,11 @@ int main(int argc, char **argv)
unsigned long tmp;
if (fscanf(fp, "%lu", &tmp) == 1) {
mmap_min_addr = tmp;
- qemu_log("host mmap_min_addr=0x%lx\n", mmap_min_addr);
+ qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx\n", mmap_min_addr);
}
fclose(fp);
}
}
-#endif /* CONFIG_USE_GUEST_BASE */
if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
printf("Error loading %s\n", filename);
@@ -963,10 +951,8 @@ int main(int argc, char **argv)
free(target_environ);
- if (qemu_log_enabled()) {
-#if defined(CONFIG_USE_GUEST_BASE)
+ if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
qemu_log("guest_base 0x%lx\n", guest_base);
-#endif
log_page_dump();
qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
@@ -986,12 +972,10 @@ int main(int argc, char **argv)
syscall_init();
signal_init();
-#if defined(CONFIG_USE_GUEST_BASE)
/* Now that we've loaded the binary, GUEST_BASE is fixed. Delay
generating the prologue until now so that the prologue can take
the real value of GUEST_BASE into account. */
tcg_prologue_init(&tcg_ctx);
-#endif
/* build Task State */
memset(ts, 0, sizeof(TaskState));
diff --git a/qemu/bsd-user/mmap.c b/qemu/bsd-user/mmap.c
index 092bf7f89..6ab533470 100644
--- a/qemu/bsd-user/mmap.c
+++ b/qemu/bsd-user/mmap.c
@@ -16,12 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
+#include "qemu/osdep.h"
#include <sys/mman.h>
#include "qemu.h"
diff --git a/qemu/bsd-user/qemu.h b/qemu/bsd-user/qemu.h
index 5362297fe..03b502ad3 100644
--- a/qemu/bsd-user/qemu.h
+++ b/qemu/bsd-user/qemu.h
@@ -17,15 +17,12 @@
#ifndef QEMU_H
#define QEMU_H
-#include <signal.h>
-#include <string.h>
#include "cpu.h"
#include "exec/cpu_ldst.h"
#undef DEBUG_REMAP
#ifdef DEBUG_REMAP
-#include <stdlib.h>
#endif /* DEBUG_REMAP */
#include "exec/user/abitypes.h"
@@ -38,7 +35,7 @@ enum BSDType {
extern enum BSDType bsd_type;
#include "syscall_defs.h"
-#include "syscall.h"
+#include "target_syscall.h"
#include "target_signal.h"
#include "exec/gdbstub.h"
@@ -101,9 +98,7 @@ typedef struct TaskState {
void init_task_state(TaskState *ts);
extern const char *qemu_uname_release;
-#if defined(CONFIG_USE_GUEST_BASE)
extern unsigned long mmap_min_addr;
-#endif
/* ??? See if we can avoid exposing so much of the loader internals. */
/*
@@ -213,8 +208,6 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
abi_ulong new_addr);
int target_msync(abi_ulong start, abi_ulong len, int flags);
extern unsigned long last_brk;
-void mmap_lock(void);
-void mmap_unlock(void);
void cpu_list_lock(void);
void cpu_list_unlock(void);
#if defined(CONFIG_USE_NPTL)
diff --git a/qemu/bsd-user/signal.c b/qemu/bsd-user/signal.c
index 445f69e83..f6f7aa242 100644
--- a/qemu/bsd-user/signal.c
+++ b/qemu/bsd-user/signal.c
@@ -16,19 +16,11 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
+#include "qemu/osdep.h"
#include "qemu.h"
#include "target_signal.h"
-//#define DEBUG_SIGNAL
-
void signal_init(void)
{
}
diff --git a/qemu/bsd-user/sparc/syscall.h b/qemu/bsd-user/sparc/target_syscall.h
index 5a9bb7e54..c7eec6ba6 100644
--- a/qemu/bsd-user/sparc/syscall.h
+++ b/qemu/bsd-user/sparc/target_syscall.h
@@ -1,3 +1,6 @@
+#ifndef TARGET_SYSCALL_H
+#define TARGET_SYSCALL_H
+
struct target_pt_regs {
abi_ulong psr;
abi_ulong pc;
@@ -7,3 +10,5 @@ struct target_pt_regs {
};
#define UNAME_MACHINE "sun4"
+
+#endif /* TARGET_SYSCALL_H */
diff --git a/qemu/bsd-user/sparc64/syscall.h b/qemu/bsd-user/sparc64/target_syscall.h
index 81a816de9..2f06100ae 100644
--- a/qemu/bsd-user/sparc64/syscall.h
+++ b/qemu/bsd-user/sparc64/target_syscall.h
@@ -1,3 +1,6 @@
+#ifndef TARGET_SYSCALL_H
+#define TARGET_SYSCALL_H
+
struct target_pt_regs {
abi_ulong u_regs[16];
abi_ulong tstate;
@@ -8,3 +11,5 @@ struct target_pt_regs {
};
#define UNAME_MACHINE "sun4u"
+
+#endif /* TARGET_SYSCALL_H */
diff --git a/qemu/bsd-user/strace.c b/qemu/bsd-user/strace.c
index e33dd4d48..fa66fe1ee 100644
--- a/qemu/bsd-user/strace.c
+++ b/qemu/bsd-user/strace.c
@@ -16,14 +16,10 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
-#include <errno.h>
+#include "qemu/osdep.h"
#include <sys/select.h>
-#include <sys/types.h>
-#include <unistd.h>
#include <sys/syscall.h>
#include <sys/ioccom.h>
-#include <ctype.h>
#include "qemu.h"
diff --git a/qemu/bsd-user/syscall.c b/qemu/bsd-user/syscall.c
index a4d1583fe..47cf865a3 100644
--- a/qemu/bsd-user/syscall.c
+++ b/qemu/bsd-user/syscall.c
@@ -16,17 +16,9 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-#include <limits.h>
-#include <sys/types.h>
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/param.h>
diff --git a/qemu/bsd-user/uaccess.c b/qemu/bsd-user/uaccess.c
index 677f19c26..91e206793 100644
--- a/qemu/bsd-user/uaccess.c
+++ b/qemu/bsd-user/uaccess.c
@@ -1,6 +1,6 @@
/* User memory access */
-#include <stdio.h>
-#include <string.h>
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include "qemu.h"
@@ -51,7 +51,7 @@ abi_long target_strlen(abi_ulong guest_addr1)
ptr = lock_user(VERIFY_READ, guest_addr, max_len, 1);
if (!ptr)
return -TARGET_EFAULT;
- len = qemu_strnlen((char *)ptr, max_len);
+ len = qemu_strnlen((const char *)ptr, max_len);
unlock_user(ptr, guest_addr, 0);
guest_addr += len;
/* we don't allow wrapping or integer overflow */
diff --git a/qemu/bsd-user/x86_64/syscall.h b/qemu/bsd-user/x86_64/target_syscall.h
index 630514a93..85a976697 100644
--- a/qemu/bsd-user/x86_64/syscall.h
+++ b/qemu/bsd-user/x86_64/target_syscall.h
@@ -1,3 +1,6 @@
+#ifndef TARGET_SYSCALL_H
+#define TARGET_SYSCALL_H
+
#define __USER_CS (0x33)
#define __USER_DS (0x2B)
@@ -114,3 +117,5 @@ struct target_msqid64_ds {
#define TARGET_ARCH_SET_FS 0x1002
#define TARGET_ARCH_GET_FS 0x1003
#define TARGET_ARCH_GET_GS 0x1004
+
+#endif /* TARGET_SYSCALL_H */