From 437fd90c0250dee670290f9b714253671a990160 Mon Sep 17 00:00:00 2001 From: José Pekkarinen Date: Wed, 18 May 2016 13:18:31 +0300 Subject: These changes are the raw update to qemu-2.6. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- qemu/bsd-user/bsdload.c | 8 +- qemu/bsd-user/elfload.c | 18 +--- qemu/bsd-user/i386/syscall.h | 161 -------------------------------- qemu/bsd-user/i386/target_syscall.h | 165 +++++++++++++++++++++++++++++++++ qemu/bsd-user/main.c | 30 ++---- qemu/bsd-user/mmap.c | 7 +- qemu/bsd-user/qemu.h | 9 +- qemu/bsd-user/signal.c | 10 +- qemu/bsd-user/sparc/syscall.h | 9 -- qemu/bsd-user/sparc/target_syscall.h | 14 +++ qemu/bsd-user/sparc64/syscall.h | 10 -- qemu/bsd-user/sparc64/target_syscall.h | 15 +++ qemu/bsd-user/strace.c | 6 +- qemu/bsd-user/syscall.c | 14 +-- qemu/bsd-user/uaccess.c | 6 +- qemu/bsd-user/x86_64/syscall.h | 116 ----------------------- qemu/bsd-user/x86_64/target_syscall.h | 121 ++++++++++++++++++++++++ 17 files changed, 337 insertions(+), 382 deletions(-) delete mode 100644 qemu/bsd-user/i386/syscall.h create mode 100644 qemu/bsd-user/i386/target_syscall.h delete mode 100644 qemu/bsd-user/sparc/syscall.h create mode 100644 qemu/bsd-user/sparc/target_syscall.h delete mode 100644 qemu/bsd-user/sparc64/syscall.h create mode 100644 qemu/bsd-user/sparc64/target_syscall.h delete mode 100644 qemu/bsd-user/x86_64/syscall.h create mode 100644 qemu/bsd-user/x86_64/target_syscall.h (limited to 'qemu/bsd-user') 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 -#include -#include -#include -#include -#include -#include +#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 -#include -#include -#include -#include +#include "qemu/osdep.h" #include -#include -#include #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/syscall.h deleted file mode 100644 index 9b34c61bb..000000000 --- a/qemu/bsd-user/i386/syscall.h +++ /dev/null @@ -1,161 +0,0 @@ -/* default linux values for the selectors */ -#define __USER_CS (0x23) -#define __USER_DS (0x2B) - -struct target_pt_regs { - long ebx; - long ecx; - long edx; - long esi; - long edi; - long ebp; - long eax; - int xds; - int xes; - long orig_eax; - long eip; - int xcs; - long eflags; - long esp; - int xss; -}; - -/* ioctls */ - -#define TARGET_LDT_ENTRIES 8192 -#define TARGET_LDT_ENTRY_SIZE 8 - -#define TARGET_GDT_ENTRIES 9 -#define TARGET_GDT_ENTRY_TLS_ENTRIES 3 -#define TARGET_GDT_ENTRY_TLS_MIN 6 -#define TARGET_GDT_ENTRY_TLS_MAX (TARGET_GDT_ENTRY_TLS_MIN + TARGET_GDT_ENTRY_TLS_ENTRIES - 1) - -struct target_modify_ldt_ldt_s { - unsigned int entry_number; - abi_ulong base_addr; - unsigned int limit; - unsigned int flags; -}; - -/* vm86 defines */ - -#define TARGET_BIOSSEG 0x0f000 - -#define TARGET_CPU_086 0 -#define TARGET_CPU_186 1 -#define TARGET_CPU_286 2 -#define TARGET_CPU_386 3 -#define TARGET_CPU_486 4 -#define TARGET_CPU_586 5 - -#define TARGET_VM86_SIGNAL 0 /* return due to signal */ -#define TARGET_VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ -#define TARGET_VM86_INTx 2 /* int3/int x instruction (ARG = x) */ -#define TARGET_VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ - -/* - * Additional return values when invoking new vm86() - */ -#define TARGET_VM86_PICRETURN 4 /* return due to pending PIC request */ -#define TARGET_VM86_TRAP 6 /* return due to DOS-debugger request */ - -/* - * function codes when invoking new vm86() - */ -#define TARGET_VM86_PLUS_INSTALL_CHECK 0 -#define TARGET_VM86_ENTER 1 -#define TARGET_VM86_ENTER_NO_BYPASS 2 -#define TARGET_VM86_REQUEST_IRQ 3 -#define TARGET_VM86_FREE_IRQ 4 -#define TARGET_VM86_GET_IRQ_BITS 5 -#define TARGET_VM86_GET_AND_RESET_IRQ 6 - -/* - * This is the stack-layout seen by the user space program when we have - * done a translation of "SAVE_ALL" from vm86 mode. The real kernel layout - * is 'kernel_vm86_regs' (see below). - */ - -struct target_vm86_regs { -/* - * normal regs, with special meaning for the segment descriptors.. - */ - abi_long ebx; - abi_long ecx; - abi_long edx; - abi_long esi; - abi_long edi; - abi_long ebp; - abi_long eax; - abi_long __null_ds; - abi_long __null_es; - abi_long __null_fs; - abi_long __null_gs; - abi_long orig_eax; - abi_long eip; - unsigned short cs, __csh; - abi_long eflags; - abi_long esp; - unsigned short ss, __ssh; -/* - * these are specific to v86 mode: - */ - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned short fs, __fsh; - unsigned short gs, __gsh; -}; - -struct target_revectored_struct { - abi_ulong __map[8]; /* 256 bits */ -}; - -struct target_vm86_struct { - struct target_vm86_regs regs; - abi_ulong flags; - abi_ulong screen_bitmap; - abi_ulong cpu_type; - struct target_revectored_struct int_revectored; - struct target_revectored_struct int21_revectored; -}; - -/* - * flags masks - */ -#define TARGET_VM86_SCREEN_BITMAP 0x0001 - -struct target_vm86plus_info_struct { - abi_ulong flags; -#define TARGET_force_return_for_pic (1 << 0) -#define TARGET_vm86dbg_active (1 << 1) /* for debugger */ -#define TARGET_vm86dbg_TFpendig (1 << 2) /* for debugger */ -#define TARGET_is_vm86pus (1 << 31) /* for vm86 internal use */ - unsigned char vm86dbg_intxxtab[32]; /* for debugger */ -}; - -struct target_vm86plus_struct { - struct target_vm86_regs regs; - abi_ulong flags; - abi_ulong screen_bitmap; - abi_ulong cpu_type; - struct target_revectored_struct int_revectored; - struct target_revectored_struct int21_revectored; - struct target_vm86plus_info_struct vm86plus; -}; - -/* FreeBSD sysarch(2) */ -#define TARGET_FREEBSD_I386_GET_LDT 0 -#define TARGET_FREEBSD_I386_SET_LDT 1 - /* I386_IOPL */ -#define TARGET_FREEBSD_I386_GET_IOPERM 3 -#define TARGET_FREEBSD_I386_SET_IOPERM 4 - /* xxxxx */ -#define TARGET_FREEBSD_I386_VM86 6 -#define TARGET_FREEBSD_I386_GET_FSBASE 7 -#define TARGET_FREEBSD_I386_SET_FSBASE 8 -#define TARGET_FREEBSD_I386_GET_GSBASE 9 -#define TARGET_FREEBSD_I386_SET_GSBASE 10 - - -#define UNAME_MACHINE "i386" - diff --git a/qemu/bsd-user/i386/target_syscall.h b/qemu/bsd-user/i386/target_syscall.h new file mode 100644 index 000000000..82d1c58ca --- /dev/null +++ b/qemu/bsd-user/i386/target_syscall.h @@ -0,0 +1,165 @@ +#ifndef TARGET_SYSCALL_H +#define TARGET_SYSCALL_H + +/* default linux values for the selectors */ +#define __USER_CS (0x23) +#define __USER_DS (0x2B) + +struct target_pt_regs { + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + int xds; + int xes; + long orig_eax; + long eip; + int xcs; + long eflags; + long esp; + int xss; +}; + +/* ioctls */ + +#define TARGET_LDT_ENTRIES 8192 +#define TARGET_LDT_ENTRY_SIZE 8 + +#define TARGET_GDT_ENTRIES 9 +#define TARGET_GDT_ENTRY_TLS_ENTRIES 3 +#define TARGET_GDT_ENTRY_TLS_MIN 6 +#define TARGET_GDT_ENTRY_TLS_MAX (TARGET_GDT_ENTRY_TLS_MIN + TARGET_GDT_ENTRY_TLS_ENTRIES - 1) + +struct target_modify_ldt_ldt_s { + unsigned int entry_number; + abi_ulong base_addr; + unsigned int limit; + unsigned int flags; +}; + +/* vm86 defines */ + +#define TARGET_BIOSSEG 0x0f000 + +#define TARGET_CPU_086 0 +#define TARGET_CPU_186 1 +#define TARGET_CPU_286 2 +#define TARGET_CPU_386 3 +#define TARGET_CPU_486 4 +#define TARGET_CPU_586 5 + +#define TARGET_VM86_SIGNAL 0 /* return due to signal */ +#define TARGET_VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ +#define TARGET_VM86_INTx 2 /* int3/int x instruction (ARG = x) */ +#define TARGET_VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ + +/* + * Additional return values when invoking new vm86() + */ +#define TARGET_VM86_PICRETURN 4 /* return due to pending PIC request */ +#define TARGET_VM86_TRAP 6 /* return due to DOS-debugger request */ + +/* + * function codes when invoking new vm86() + */ +#define TARGET_VM86_PLUS_INSTALL_CHECK 0 +#define TARGET_VM86_ENTER 1 +#define TARGET_VM86_ENTER_NO_BYPASS 2 +#define TARGET_VM86_REQUEST_IRQ 3 +#define TARGET_VM86_FREE_IRQ 4 +#define TARGET_VM86_GET_IRQ_BITS 5 +#define TARGET_VM86_GET_AND_RESET_IRQ 6 + +/* + * This is the stack-layout seen by the user space program when we have + * done a translation of "SAVE_ALL" from vm86 mode. The real kernel layout + * is 'kernel_vm86_regs' (see below). + */ + +struct target_vm86_regs { +/* + * normal regs, with special meaning for the segment descriptors.. + */ + abi_long ebx; + abi_long ecx; + abi_long edx; + abi_long esi; + abi_long edi; + abi_long ebp; + abi_long eax; + abi_long __null_ds; + abi_long __null_es; + abi_long __null_fs; + abi_long __null_gs; + abi_long orig_eax; + abi_long eip; + unsigned short cs, __csh; + abi_long eflags; + abi_long esp; + unsigned short ss, __ssh; +/* + * these are specific to v86 mode: + */ + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned short fs, __fsh; + unsigned short gs, __gsh; +}; + +struct target_revectored_struct { + abi_ulong __map[8]; /* 256 bits */ +}; + +struct target_vm86_struct { + struct target_vm86_regs regs; + abi_ulong flags; + abi_ulong screen_bitmap; + abi_ulong cpu_type; + struct target_revectored_struct int_revectored; + struct target_revectored_struct int21_revectored; +}; + +/* + * flags masks + */ +#define TARGET_VM86_SCREEN_BITMAP 0x0001 + +struct target_vm86plus_info_struct { + abi_ulong flags; +#define TARGET_force_return_for_pic (1 << 0) +#define TARGET_vm86dbg_active (1 << 1) /* for debugger */ +#define TARGET_vm86dbg_TFpendig (1 << 2) /* for debugger */ +#define TARGET_is_vm86pus (1 << 31) /* for vm86 internal use */ + unsigned char vm86dbg_intxxtab[32]; /* for debugger */ +}; + +struct target_vm86plus_struct { + struct target_vm86_regs regs; + abi_ulong flags; + abi_ulong screen_bitmap; + abi_ulong cpu_type; + struct target_revectored_struct int_revectored; + struct target_revectored_struct int21_revectored; + struct target_vm86plus_info_struct vm86plus; +}; + +/* FreeBSD sysarch(2) */ +#define TARGET_FREEBSD_I386_GET_LDT 0 +#define TARGET_FREEBSD_I386_SET_LDT 1 + /* I386_IOPL */ +#define TARGET_FREEBSD_I386_GET_IOPERM 3 +#define TARGET_FREEBSD_I386_SET_IOPERM 4 + /* xxxxx */ +#define TARGET_FREEBSD_I386_VM86 6 +#define TARGET_FREEBSD_I386_GET_FSBASE 7 +#define TARGET_FREEBSD_I386_SET_FSBASE 8 +#define TARGET_FREEBSD_I386_GET_GSBASE 9 +#define TARGET_FREEBSD_I386_SET_GSBASE 10 + + +#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 . */ -#include -#include -#include -#include -#include -#include +#include "qemu/osdep.h" #include -#include #include #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 . */ -#include -#include -#include -#include -#include -#include +#include "qemu/osdep.h" #include #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 -#include #include "cpu.h" #include "exec/cpu_ldst.h" #undef DEBUG_REMAP #ifdef DEBUG_REMAP -#include #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 . */ -#include -#include -#include -#include -#include -#include -#include +#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/syscall.h deleted file mode 100644 index 5a9bb7e54..000000000 --- a/qemu/bsd-user/sparc/syscall.h +++ /dev/null @@ -1,9 +0,0 @@ -struct target_pt_regs { - abi_ulong psr; - abi_ulong pc; - abi_ulong npc; - abi_ulong y; - abi_ulong u_regs[16]; -}; - -#define UNAME_MACHINE "sun4" diff --git a/qemu/bsd-user/sparc/target_syscall.h b/qemu/bsd-user/sparc/target_syscall.h new file mode 100644 index 000000000..c7eec6ba6 --- /dev/null +++ b/qemu/bsd-user/sparc/target_syscall.h @@ -0,0 +1,14 @@ +#ifndef TARGET_SYSCALL_H +#define TARGET_SYSCALL_H + +struct target_pt_regs { + abi_ulong psr; + abi_ulong pc; + abi_ulong npc; + abi_ulong y; + abi_ulong u_regs[16]; +}; + +#define UNAME_MACHINE "sun4" + +#endif /* TARGET_SYSCALL_H */ diff --git a/qemu/bsd-user/sparc64/syscall.h b/qemu/bsd-user/sparc64/syscall.h deleted file mode 100644 index 81a816de9..000000000 --- a/qemu/bsd-user/sparc64/syscall.h +++ /dev/null @@ -1,10 +0,0 @@ -struct target_pt_regs { - abi_ulong u_regs[16]; - abi_ulong tstate; - abi_ulong pc; - abi_ulong npc; - abi_ulong y; - abi_ulong fprs; -}; - -#define UNAME_MACHINE "sun4u" diff --git a/qemu/bsd-user/sparc64/target_syscall.h b/qemu/bsd-user/sparc64/target_syscall.h new file mode 100644 index 000000000..2f06100ae --- /dev/null +++ b/qemu/bsd-user/sparc64/target_syscall.h @@ -0,0 +1,15 @@ +#ifndef TARGET_SYSCALL_H +#define TARGET_SYSCALL_H + +struct target_pt_regs { + abi_ulong u_regs[16]; + abi_ulong tstate; + abi_ulong pc; + abi_ulong npc; + abi_ulong y; + abi_ulong fprs; +}; + +#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 . */ -#include -#include +#include "qemu/osdep.h" #include -#include -#include #include #include -#include #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 . */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/path.h" #include #include #include 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 -#include +#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/syscall.h deleted file mode 100644 index 630514a93..000000000 --- a/qemu/bsd-user/x86_64/syscall.h +++ /dev/null @@ -1,116 +0,0 @@ -#define __USER_CS (0x33) -#define __USER_DS (0x2B) - -struct target_pt_regs { - abi_ulong r15; - abi_ulong r14; - abi_ulong r13; - abi_ulong r12; - abi_ulong rbp; - abi_ulong rbx; -/* arguments: non interrupts/non tracing syscalls only save up to here */ - abi_ulong r11; - abi_ulong r10; - abi_ulong r9; - abi_ulong r8; - abi_ulong rax; - abi_ulong rcx; - abi_ulong rdx; - abi_ulong rsi; - abi_ulong rdi; - abi_ulong orig_rax; -/* end of arguments */ -/* cpu exception frame or undefined */ - abi_ulong rip; - abi_ulong cs; - abi_ulong eflags; - abi_ulong rsp; - abi_ulong ss; -/* top of stack page */ -}; - -/* Maximum number of LDT entries supported. */ -#define TARGET_LDT_ENTRIES 8192 -/* The size of each LDT entry. */ -#define TARGET_LDT_ENTRY_SIZE 8 - -#define TARGET_GDT_ENTRIES 16 -#define TARGET_GDT_ENTRY_TLS_ENTRIES 3 -#define TARGET_GDT_ENTRY_TLS_MIN 12 -#define TARGET_GDT_ENTRY_TLS_MAX 14 - -#if 0 // Redefine this -struct target_modify_ldt_ldt_s { - unsigned int entry_number; - abi_ulong base_addr; - unsigned int limit; - unsigned int seg_32bit:1; - unsigned int contents:2; - unsigned int read_exec_only:1; - unsigned int limit_in_pages:1; - unsigned int seg_not_present:1; - unsigned int useable:1; - unsigned int lm:1; -}; -#else -struct target_modify_ldt_ldt_s { - unsigned int entry_number; - abi_ulong base_addr; - unsigned int limit; - unsigned int flags; -}; -#endif - -struct target_ipc64_perm -{ - int key; - uint32_t uid; - uint32_t gid; - uint32_t cuid; - uint32_t cgid; - unsigned short mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - abi_ulong __unused1; - abi_ulong __unused2; -}; - -struct target_msqid64_ds { - struct target_ipc64_perm msg_perm; - unsigned int msg_stime; /* last msgsnd time */ - unsigned int msg_rtime; /* last msgrcv time */ - unsigned int msg_ctime; /* last change time */ - abi_ulong msg_cbytes; /* current number of bytes on queue */ - abi_ulong msg_qnum; /* number of messages in queue */ - abi_ulong msg_qbytes; /* max number of bytes on queue */ - unsigned int msg_lspid; /* pid of last msgsnd */ - unsigned int msg_lrpid; /* last receive pid */ - abi_ulong __unused4; - abi_ulong __unused5; -}; - -/* FreeBSD sysarch(2) */ -#define TARGET_FREEBSD_I386_GET_LDT 0 -#define TARGET_FREEBSD_I386_SET_LDT 1 - /* I386_IOPL */ -#define TARGET_FREEBSD_I386_GET_IOPERM 3 -#define TARGET_FREEBSD_I386_SET_IOPERM 4 - /* xxxxx */ -#define TARGET_FREEBSD_I386_GET_FSBASE 7 -#define TARGET_FREEBSD_I386_SET_FSBASE 8 -#define TARGET_FREEBSD_I386_GET_GSBASE 9 -#define TARGET_FREEBSD_I386_SET_GSBASE 10 - -#define TARGET_FREEBSD_AMD64_GET_FSBASE 128 -#define TARGET_FREEBSD_AMD64_SET_FSBASE 129 -#define TARGET_FREEBSD_AMD64_GET_GSBASE 130 -#define TARGET_FREEBSD_AMD64_SET_GSBASE 131 - - -#define UNAME_MACHINE "x86_64" - -#define TARGET_ARCH_SET_GS 0x1001 -#define TARGET_ARCH_SET_FS 0x1002 -#define TARGET_ARCH_GET_FS 0x1003 -#define TARGET_ARCH_GET_GS 0x1004 diff --git a/qemu/bsd-user/x86_64/target_syscall.h b/qemu/bsd-user/x86_64/target_syscall.h new file mode 100644 index 000000000..85a976697 --- /dev/null +++ b/qemu/bsd-user/x86_64/target_syscall.h @@ -0,0 +1,121 @@ +#ifndef TARGET_SYSCALL_H +#define TARGET_SYSCALL_H + +#define __USER_CS (0x33) +#define __USER_DS (0x2B) + +struct target_pt_regs { + abi_ulong r15; + abi_ulong r14; + abi_ulong r13; + abi_ulong r12; + abi_ulong rbp; + abi_ulong rbx; +/* arguments: non interrupts/non tracing syscalls only save up to here */ + abi_ulong r11; + abi_ulong r10; + abi_ulong r9; + abi_ulong r8; + abi_ulong rax; + abi_ulong rcx; + abi_ulong rdx; + abi_ulong rsi; + abi_ulong rdi; + abi_ulong orig_rax; +/* end of arguments */ +/* cpu exception frame or undefined */ + abi_ulong rip; + abi_ulong cs; + abi_ulong eflags; + abi_ulong rsp; + abi_ulong ss; +/* top of stack page */ +}; + +/* Maximum number of LDT entries supported. */ +#define TARGET_LDT_ENTRIES 8192 +/* The size of each LDT entry. */ +#define TARGET_LDT_ENTRY_SIZE 8 + +#define TARGET_GDT_ENTRIES 16 +#define TARGET_GDT_ENTRY_TLS_ENTRIES 3 +#define TARGET_GDT_ENTRY_TLS_MIN 12 +#define TARGET_GDT_ENTRY_TLS_MAX 14 + +#if 0 // Redefine this +struct target_modify_ldt_ldt_s { + unsigned int entry_number; + abi_ulong base_addr; + unsigned int limit; + unsigned int seg_32bit:1; + unsigned int contents:2; + unsigned int read_exec_only:1; + unsigned int limit_in_pages:1; + unsigned int seg_not_present:1; + unsigned int useable:1; + unsigned int lm:1; +}; +#else +struct target_modify_ldt_ldt_s { + unsigned int entry_number; + abi_ulong base_addr; + unsigned int limit; + unsigned int flags; +}; +#endif + +struct target_ipc64_perm +{ + int key; + uint32_t uid; + uint32_t gid; + uint32_t cuid; + uint32_t cgid; + unsigned short mode; + unsigned short __pad1; + unsigned short seq; + unsigned short __pad2; + abi_ulong __unused1; + abi_ulong __unused2; +}; + +struct target_msqid64_ds { + struct target_ipc64_perm msg_perm; + unsigned int msg_stime; /* last msgsnd time */ + unsigned int msg_rtime; /* last msgrcv time */ + unsigned int msg_ctime; /* last change time */ + abi_ulong msg_cbytes; /* current number of bytes on queue */ + abi_ulong msg_qnum; /* number of messages in queue */ + abi_ulong msg_qbytes; /* max number of bytes on queue */ + unsigned int msg_lspid; /* pid of last msgsnd */ + unsigned int msg_lrpid; /* last receive pid */ + abi_ulong __unused4; + abi_ulong __unused5; +}; + +/* FreeBSD sysarch(2) */ +#define TARGET_FREEBSD_I386_GET_LDT 0 +#define TARGET_FREEBSD_I386_SET_LDT 1 + /* I386_IOPL */ +#define TARGET_FREEBSD_I386_GET_IOPERM 3 +#define TARGET_FREEBSD_I386_SET_IOPERM 4 + /* xxxxx */ +#define TARGET_FREEBSD_I386_GET_FSBASE 7 +#define TARGET_FREEBSD_I386_SET_FSBASE 8 +#define TARGET_FREEBSD_I386_GET_GSBASE 9 +#define TARGET_FREEBSD_I386_SET_GSBASE 10 + +#define TARGET_FREEBSD_AMD64_GET_FSBASE 128 +#define TARGET_FREEBSD_AMD64_SET_FSBASE 129 +#define TARGET_FREEBSD_AMD64_GET_GSBASE 130 +#define TARGET_FREEBSD_AMD64_SET_GSBASE 131 + + +#define UNAME_MACHINE "x86_64" + +#define TARGET_ARCH_SET_GS 0x1001 +#define TARGET_ARCH_SET_FS 0x1002 +#define TARGET_ARCH_GET_FS 0x1003 +#define TARGET_ARCH_GET_GS 0x1004 + +#endif /* TARGET_SYSCALL_H */ -- cgit 1.2.3-korg