aboutsummaryrefslogtreecommitdiff
path: root/emulators
diff options
context:
space:
mode:
authorJuergen Lock <nox@FreeBSD.org>2014-12-02 21:32:55 +0000
committerJuergen Lock <nox@FreeBSD.org>2014-12-02 21:32:55 +0000
commit2b33b0e94d556d12a11383622c8d7ed0d6e82469 (patch)
tree83351c597f955d59b8c9b5e3bba5ff7f2833e888 /emulators
parent32ce6c2a9371b04af2f99fbf105baf9824838edc (diff)
downloadports-2b33b0e94d556d12a11383622c8d7ed0d6e82469.tar.gz
ports-2b33b0e94d556d12a11383622c8d7ed0d6e82469.zip
Notes
Diffstat (limited to 'emulators')
-rw-r--r--emulators/qemu-devel/Makefile9
-rw-r--r--emulators/qemu-devel/files/extra-patch-22aae36fc2227aa772ebbc701f45319464ecae4d23
-rw-r--r--emulators/qemu-devel/files/extra-patch-26a50e8a9d8723d406e5ef3d1449911cfa2d345462
-rw-r--r--emulators/qemu-devel/files/extra-patch-290a6e398b9d132a673e1f95954fc7d9a86c3baa76
-rw-r--r--emulators/qemu-devel/files/extra-patch-a72c668c8ab84c24372ff664d9b853c2a42d37b191
-rw-r--r--emulators/qemu-devel/files/extra-patch-d5c3fb7b75b4ea80e09bf3cb7ff6dd1061968d6e86
-rw-r--r--emulators/qemu-devel/files/extra-patch-f254372f13ab5cd8f25bd1ca8641ce6d67bff3fe170
-rw-r--r--emulators/qemu-devel/files/extra-patch-f4319eb1a3a8393930570f061bdac6abe007b2bb56
8 files changed, 572 insertions, 1 deletions
diff --git a/emulators/qemu-devel/Makefile b/emulators/qemu-devel/Makefile
index b755c581fc93..d743178ad04a 100644
--- a/emulators/qemu-devel/Makefile
+++ b/emulators/qemu-devel/Makefile
@@ -3,7 +3,7 @@
PORTNAME= qemu
PORTVERSION= 2.0.2
-PORTREVISION= 9
+PORTREVISION= 10
CATEGORIES= emulators
MASTER_SITES= http://wiki.qemu.org/download/:release \
LOCAL/nox:snapshot
@@ -99,6 +99,13 @@ EXTRA_PATCHES+= ${FILESDIR}/extra-patch-a8dc4de7f73bc6f8363c0fc81c4c6e53733c444b
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-bsd-user-freebsd-os-socket.h
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-cab0d36ffd4e70b1879dc2cf860c975a7965afc3
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-8267ad2cb92b106bb16e91234f04abc49ab32036
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-290a6e398b9d132a673e1f95954fc7d9a86c3baa
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-26a50e8a9d8723d406e5ef3d1449911cfa2d3454
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-22aae36fc2227aa772ebbc701f45319464ecae4d
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-a72c668c8ab84c24372ff664d9b853c2a42d37b1
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-d5c3fb7b75b4ea80e09bf3cb7ff6dd1061968d6e
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-f4319eb1a3a8393930570f061bdac6abe007b2bb
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-f254372f13ab5cd8f25bd1ca8641ce6d67bff3fe
.endif
CONFIGURE_ARGS+= --localstatedir=/var
diff --git a/emulators/qemu-devel/files/extra-patch-22aae36fc2227aa772ebbc701f45319464ecae4d b/emulators/qemu-devel/files/extra-patch-22aae36fc2227aa772ebbc701f45319464ecae4d
new file mode 100644
index 000000000000..dc8c1e695d26
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-22aae36fc2227aa772ebbc701f45319464ecae4d
@@ -0,0 +1,23 @@
+From 22aae36fc2227aa772ebbc701f45319464ecae4d Mon Sep 17 00:00:00 2001
+From: Sean Bruno <sbruno@crack.ysv.freebsd.org>
+Date: Sat, 29 Nov 2014 23:02:36 +0000
+Subject: [PATCH] Change UX/AWRAP to allow compile. Probably, this is part of
+ the problem
+
+---
+ bsd-user/mips64/target_arch_cpu.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/bsd-user/mips64/target_arch_cpu.h b/bsd-user/mips64/target_arch_cpu.h
+index f4e212f..0619f5b 100644
+--- a/bsd-user/mips64/target_arch_cpu.h
++++ b/bsd-user/mips64/target_arch_cpu.h
+@@ -42,7 +42,7 @@ static inline void target_cpu_init(CPUMIPSState *env,
+ if (regs->cp0_epc & 1) {
+ env->hflags |= MIPS_HFLAG_M16;
+ }
+- env->hflags |= MIPS_HFLAG_UX | MIPS_HFLAG_64;
++ env->hflags |= MIPS_HFLAG_AWRAP | MIPS_HFLAG_64;
+ }
+
+ static int do_store_exclusive(CPUMIPSState *env)
diff --git a/emulators/qemu-devel/files/extra-patch-26a50e8a9d8723d406e5ef3d1449911cfa2d3454 b/emulators/qemu-devel/files/extra-patch-26a50e8a9d8723d406e5ef3d1449911cfa2d3454
new file mode 100644
index 000000000000..44194816d201
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-26a50e8a9d8723d406e5ef3d1449911cfa2d3454
@@ -0,0 +1,62 @@
+From 26a50e8a9d8723d406e5ef3d1449911cfa2d3454 Mon Sep 17 00:00:00 2001
+From: Leon Alrae <leon.alrae@imgtec.com>
+Date: Fri, 27 Jun 2014 08:49:00 +0100
+Subject: [PATCH] target-mips: define ISA_MIPS64R6
+
+Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
+Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
+---
+ target-mips/mips-defs.h | 28 +++++++++++++++++++---------
+ 1 file changed, 19 insertions(+), 9 deletions(-)
+
+diff --git a/target-mips/mips-defs.h b/target-mips/mips-defs.h
+index 9dfa516..6cb62b2 100644
+--- a/target-mips/mips-defs.h
++++ b/target-mips/mips-defs.h
+@@ -30,17 +30,21 @@
+ #define ISA_MIPS64 0x00000080
+ #define ISA_MIPS64R2 0x00000100
+ #define ISA_MIPS32R3 0x00000200
+-#define ISA_MIPS32R5 0x00000400
++#define ISA_MIPS64R3 0x00000400
++#define ISA_MIPS32R5 0x00000800
++#define ISA_MIPS64R5 0x00001000
++#define ISA_MIPS32R6 0x00002000
++#define ISA_MIPS64R6 0x00004000
+
+ /* MIPS ASEs. */
+-#define ASE_MIPS16 0x00001000
+-#define ASE_MIPS3D 0x00002000
+-#define ASE_MDMX 0x00004000
+-#define ASE_DSP 0x00008000
+-#define ASE_DSPR2 0x00010000
+-#define ASE_MT 0x00020000
+-#define ASE_SMARTMIPS 0x00040000
+-#define ASE_MICROMIPS 0x00080000
++#define ASE_MIPS16 0x00010000
++#define ASE_MIPS3D 0x00020000
++#define ASE_MDMX 0x00040000
++#define ASE_DSP 0x00080000
++#define ASE_DSPR2 0x00100000
++#define ASE_MT 0x00200000
++#define ASE_SMARTMIPS 0x00400000
++#define ASE_MICROMIPS 0x00800000
+
+ /* Chip specific instructions. */
+ #define INSN_LOONGSON2E 0x20000000
+@@ -68,9 +72,15 @@
+
+ /* MIPS Technologies "Release 3" */
+ #define CPU_MIPS32R3 (CPU_MIPS32R2 | ISA_MIPS32R3)
++#define CPU_MIPS64R3 (CPU_MIPS64R2 | CPU_MIPS32R3 | ISA_MIPS64R3)
+
+ /* MIPS Technologies "Release 5" */
+ #define CPU_MIPS32R5 (CPU_MIPS32R3 | ISA_MIPS32R5)
++#define CPU_MIPS64R5 (CPU_MIPS64R3 | CPU_MIPS32R5 | ISA_MIPS64R5)
++
++/* MIPS Technologies "Release 6" */
++#define CPU_MIPS32R6 (CPU_MIPS32R5 | ISA_MIPS32R6)
++#define CPU_MIPS64R6 (CPU_MIPS64R5 | CPU_MIPS32R6 | ISA_MIPS64R6)
+
+ /* Strictly follow the architecture standard:
+ - Disallow "special" instruction handling for PMON/SPIM.
diff --git a/emulators/qemu-devel/files/extra-patch-290a6e398b9d132a673e1f95954fc7d9a86c3baa b/emulators/qemu-devel/files/extra-patch-290a6e398b9d132a673e1f95954fc7d9a86c3baa
new file mode 100644
index 000000000000..8d9ef66fb484
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-290a6e398b9d132a673e1f95954fc7d9a86c3baa
@@ -0,0 +1,76 @@
+From 290a6e398b9d132a673e1f95954fc7d9a86c3baa Mon Sep 17 00:00:00 2001
+From: Leon Alrae <leon.alrae@imgtec.com>
+Date: Fri, 27 Jun 2014 08:49:04 +0100
+Subject: [PATCH] target-mips: Status.UX/SX/KX enable 32-bit address wrapping
+
+In R6 the special behaviour for data references is also specified for Kernel
+and Supervisor mode. Therefore MIPS_HFLAG_UX is replaced by generic
+MIPS_HFLAG_AWRAP indicating enabled 32-bit address wrapping.
+
+Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
+Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
+---
+ target-mips/cpu.h | 18 ++++++++++++++----
+ target-mips/translate.c | 6 +-----
+ 2 files changed, 15 insertions(+), 9 deletions(-)
+
+diff --git a/target-mips/cpu.h b/target-mips/cpu.h
+index 8b9a92e..51a8331 100644
+--- a/target-mips/cpu.h
++++ b/target-mips/cpu.h
+@@ -450,7 +450,7 @@ struct CPUMIPSState {
+ and RSQRT.D. */
+ #define MIPS_HFLAG_COP1X 0x00080 /* COP1X instructions enabled */
+ #define MIPS_HFLAG_RE 0x00100 /* Reversed endianness */
+-#define MIPS_HFLAG_UX 0x00200 /* 64-bit user mode */
++#define MIPS_HFLAG_AWRAP 0x00200 /* 32-bit compatibility address wrapping */
+ #define MIPS_HFLAG_M16 0x00400 /* MIPS16 mode flag */
+ #define MIPS_HFLAG_M16_SHIFT 10
+ /* If translation is interrupted between the branch instruction and
+@@ -725,7 +725,7 @@ static inline void compute_hflags(CPUMIPSState *env)
+ {
+ env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
+ MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU |
+- MIPS_HFLAG_UX | MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2);
++ MIPS_HFLAG_AWRAP | MIPS_HFLAG_DSP | MIPS_HFLAG_DSPR2);
+ if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
+ !(env->CP0_Status & (1 << CP0St_ERL)) &&
+ !(env->hflags & MIPS_HFLAG_DM)) {
+@@ -737,8 +737,18 @@ static inline void compute_hflags(CPUMIPSState *env)
+ (env->CP0_Status & (1 << CP0St_UX))) {
+ env->hflags |= MIPS_HFLAG_64;
+ }
+- if (env->CP0_Status & (1 << CP0St_UX)) {
+- env->hflags |= MIPS_HFLAG_UX;
++
++ if (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&
++ !(env->CP0_Status & (1 << CP0St_UX))) {
++ env->hflags |= MIPS_HFLAG_AWRAP;
++ } else if (env->insn_flags & ISA_MIPS32R6) {
++ /* Address wrapping for Supervisor and Kernel is specified in R6 */
++ if ((((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_SM) &&
++ !(env->CP0_Status & (1 << CP0St_SX))) ||
++ (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_KM) &&
++ !(env->CP0_Status & (1 << CP0St_KX)))) {
++ env->hflags |= MIPS_HFLAG_AWRAP;
++ }
+ }
+ #endif
+ if ((env->CP0_Status & (1 << CP0St_CU0)) ||
+diff --git a/target-mips/translate.c b/target-mips/translate.c
+index 06db150..05044b0 100644
+--- a/target-mips/translate.c
++++ b/target-mips/translate.c
+@@ -1343,11 +1343,7 @@ static inline void gen_op_addr_add (DisasContext *ctx, TCGv ret, TCGv arg0, TCGv
+ tcg_gen_add_tl(ret, arg0, arg1);
+
+ #if defined(TARGET_MIPS64)
+- /* For compatibility with 32-bit code, data reference in user mode
+- with Status_UX = 0 should be casted to 32-bit and sign extended.
+- See the MIPS64 PRA manual, section 4.10. */
+- if (((ctx->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&
+- !(ctx->hflags & MIPS_HFLAG_UX)) {
++ if (ctx->hflags & MIPS_HFLAG_AWRAP) {
+ tcg_gen_ext32s_i64(ret, ret);
+ }
+ #endif
diff --git a/emulators/qemu-devel/files/extra-patch-a72c668c8ab84c24372ff664d9b853c2a42d37b1 b/emulators/qemu-devel/files/extra-patch-a72c668c8ab84c24372ff664d9b853c2a42d37b1
new file mode 100644
index 000000000000..d3c58a53e914
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-a72c668c8ab84c24372ff664d9b853c2a42d37b1
@@ -0,0 +1,91 @@
+From a72c668c8ab84c24372ff664d9b853c2a42d37b1 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Mon, 1 Dec 2014 22:06:58 +0000
+Subject: [PATCH] Fix the pipe(2) and pipe2(2) so the file descriptors are
+ returned correctly.
+
+The pipe(2) system call returns the file descriptors in registers. The
+pipe2(2) system call copies out the file descriptors. They are not the
+same.
+---
+ bsd-user/bsd-file.h | 13 ++++++++-----
+ bsd-user/freebsd/os-file.h | 27 ++++++++++++++-------------
+ 2 files changed, 22 insertions(+), 18 deletions(-)
+
+diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
+index defa8bb..02698a3 100644
+--- a/bsd-user/bsd-file.h
++++ b/bsd-user/bsd-file.h
+@@ -1009,7 +1009,7 @@ static abi_long do_bsd_lseek(void *cpu_env, abi_long arg1, abi_long arg2,
+ ret = ((res >> 32) & 0xFFFFFFFF);
+ set_second_rval(cpu_env, res & 0xFFFFFFFF);
+ #else
+- ret = res & 0xFFFFFFFF;
++ ret = res & 0xFFFFFFFF;
+ set_second_rval(cpu_env, (res >> 32) & 0xFFFFFFFF);
+ #endif
+ }
+@@ -1027,12 +1027,15 @@ static abi_long do_bsd_pipe(void *cpu_env, abi_ulong pipedes)
+ int host_ret = pipe(host_pipe);
+
+ if (host_ret != -1) {
++ /* XXX pipe(2), unlike pipe2(), returns the second FD in a register. */
+ set_second_rval(cpu_env, host_pipe[1]);
+ ret = host_pipe[0];
+- if (put_user_s32(host_pipe[0], pipedes) ||
+- put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) {
+- return -TARGET_EFAULT;
+- }
++ /* XXX Not needed for pipe():
++ if (put_user_s32(host_pipe[0], pipedes) ||
++ put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) {
++ return -TARGET_EFAULT;
++ }
++ */
+ } else {
+ ret = get_errno(host_ret);
+ }
+diff --git a/bsd-user/freebsd/os-file.h b/bsd-user/freebsd/os-file.h
+index 0b3e8c5..bd94c84 100644
+--- a/bsd-user/freebsd/os-file.h
++++ b/bsd-user/freebsd/os-file.h
+@@ -108,25 +108,26 @@ static abi_long do_freebsd_aio_mlock(__unused abi_ulong iocb)
+ /* pipe2(2) */
+ static abi_long do_bsd_pipe2(void *cpu_env, abi_ulong pipedes, int flags)
+ {
+- abi_long ret;
+ int host_pipe[2];
+- int host_ret = pipe2(host_pipe, flags);
++ int host_ret = pipe2(host_pipe, flags); /* XXXss - flags should be
++ translated from target to host. */
+
+ if (is_error(host_ret)) {
+- return get_errno(host_ret);
++ return get_errno(host_ret);
+ }
+- if (host_ret != -1) {
+- set_second_rval(cpu_env, host_pipe[1]);
+- ret = host_pipe[0];
++ /*
++ * XXX pipe2() returns it's second FD by copying it back to
++ * userspace and not in a second register like pipe(2):
++ * set_second_rval(cpu_env, host_pipe[1]);
++ *
++ * Copy the FD's back to userspace:
++ */
+ if (put_user_s32(host_pipe[0], pipedes) ||
+- put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) {
+- return -TARGET_EFAULT;
++ put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) {
++ return -TARGET_EFAULT;
+ }
+- } else {
+- ret = get_errno(host_ret);
+- }
+- return ret;
+-}
++ return 0;
++}
+
+ /* chflagsat(2) */
+ static inline abi_long do_bsd_chflagsat(int fd, abi_ulong path,
diff --git a/emulators/qemu-devel/files/extra-patch-d5c3fb7b75b4ea80e09bf3cb7ff6dd1061968d6e b/emulators/qemu-devel/files/extra-patch-d5c3fb7b75b4ea80e09bf3cb7ff6dd1061968d6e
new file mode 100644
index 000000000000..3cf18818a909
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-d5c3fb7b75b4ea80e09bf3cb7ff6dd1061968d6e
@@ -0,0 +1,86 @@
+From d5c3fb7b75b4ea80e09bf3cb7ff6dd1061968d6e Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Tue, 2 Dec 2014 00:52:03 +0000
+Subject: [PATCH] Add sched_yield(2) and sched_get_priority_{max, min}(2)
+ syscall handlers.
+
+This change adds system call handlers and strace support for
+sched_yield(2), sched_get_priority_max(2) and sched_get_priority_min(2).
+---
+ bsd-user/bsd-proc.h | 21 ++++++++++++++++++++-
+ bsd-user/freebsd/strace.list | 2 ++
+ bsd-user/syscall.c | 13 +++++++++++++
+ 3 files changed, 35 insertions(+), 1 deletion(-)
+
+diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h
+index 5c1f91a..85dff61 100644
+--- a/bsd-user/bsd-proc.h
++++ b/bsd-user/bsd-proc.h
+@@ -443,6 +443,25 @@ static inline abi_long do_bsd_setpriority(abi_long which, abi_long who,
+ return get_errno(setpriority(which, who, prio));
+ }
+
++/* sched_yield(2) */
++static inline abi_long do_bsd_sched_yield(void)
++{
+
+-#endif /* !__BSD_PROC_H_ */
++ return get_errno(sched_yield());
++}
++
++/* sched_get_priority_min(2) */
++static inline abi_long do_bsd_sched_get_priority_min(int policy)
++{
++
++ return get_errno(sched_get_priority_min(policy));
++}
++
++/* sched_get_priority_max(2) */
++static inline abi_long do_bsd_sched_get_priority_max(int policy)
++{
+
++ return get_errno(sched_get_priority_max(policy));
++}
++
++#endif /* !__BSD_PROC_H_ */
+diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
+index 6202790..b0e32fd 100644
+--- a/bsd-user/freebsd/strace.list
++++ b/bsd-user/freebsd/strace.list
+@@ -191,6 +191,8 @@
+ { TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_rtprio_thread, "rtprio_thread", "%s(%d, %d, %p)", NULL, NULL },
+ { TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_sched_get_priority_max, "sched_get_priority_max", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_sched_get_priority_min, "sched_get_priority_min", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_select, "select", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_semget, "semget", NULL, NULL, NULL },
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index 6f467f8..0e090f4 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -1425,10 +1425,23 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_freebsd_sched_getscheduler(arg1);
+ break;
+
++ case TARGET_FREEBSD_NR_sched_get_priority_max: /* sched_get_priority_max(2)*/
++ ret = do_bsd_sched_get_priority_max(arg1);
++ break;
++
++ case TARGET_FREEBSD_NR_sched_get_priority_min: /* sched_get_priority_min(2)*/
++ ret = do_bsd_sched_get_priority_min(arg1);
++ break;
++
+ case TARGET_FREEBSD_NR_sched_rr_get_interval: /* sched_rr_get_interval(2) */
+ ret = do_freebsd_sched_rr_get_interval(arg1, arg2);
+ break;
+
++ case TARGET_FREEBSD_NR_sched_yield: /* sched_yield(2)*/
++ ret = do_bsd_sched_yield();
++ break;
++
++
+ /*
+ * FreeBSD CPU affinity sets management
+ */
diff --git a/emulators/qemu-devel/files/extra-patch-f254372f13ab5cd8f25bd1ca8641ce6d67bff3fe b/emulators/qemu-devel/files/extra-patch-f254372f13ab5cd8f25bd1ca8641ce6d67bff3fe
new file mode 100644
index 000000000000..8c5f47b3678e
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-f254372f13ab5cd8f25bd1ca8641ce6d67bff3fe
@@ -0,0 +1,170 @@
+From f254372f13ab5cd8f25bd1ca8641ce6d67bff3fe Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Tue, 2 Dec 2014 13:57:27 +0000
+Subject: [PATCH] Eliminate "Qemu unsupported ioctl" warnings for cryptodev.
+
+The host may have /dev/crypto (cryptodev) support but emulation of it
+for qemu targets is not supported. Therefore, return an error if
+it used to eliminate the generic warning message.
+---
+ bsd-user/bsd-ioctl.c | 17 ++++++-
+ bsd-user/freebsd/os-ioctl-cmds.h | 3 ++
+ bsd-user/freebsd/os-ioctl-cryptodev.h | 85 +++++++++++++++++++++++++++++++++++
+ 3 files changed, 104 insertions(+), 1 deletion(-)
+ create mode 100644 bsd-user/freebsd/os-ioctl-cryptodev.h
+
+diff --git a/bsd-user/bsd-ioctl.c b/bsd-user/bsd-ioctl.c
+index 10e8e54..ae4784a 100644
+--- a/bsd-user/bsd-ioctl.c
++++ b/bsd-user/bsd-ioctl.c
+@@ -1,7 +1,7 @@
+ /*
+ * BSD ioctl(2) emulation
+ *
+- * Copyright (c) 2013 Stacey D. Son
++ * Copyright (c) 2013-14 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -29,10 +29,13 @@
+ #include <sys/ttycom.h>
+ #include <sys/filio.h>
+
++#include <crypto/cryptodev.h>
++
+ #include "qemu.h"
+ #include "qemu-common.h"
+
+ #include "bsd-ioctl.h"
++#include "os-ioctl-cryptodev.h"
+ #include "os-ioctl-filio.h"
+ #include "os-ioctl-ttycom.h"
+
+@@ -295,6 +298,10 @@ typedef struct IOCTLEntry IOCTLEntry;
+
+ #define MAX_STRUCT_SIZE 4096
+
++static abi_long do_ioctl_unsupported(__unused const IOCTLEntry *ie,
++ __unused uint8_t *buf_temp, __unused int fd,
++ __unused abi_long cmd, __unused abi_long arg);
++
+ static IOCTLEntry ioctl_entries[] = {
+ #define IOC_ 0x0000
+ #define IOC_R 0x0001
+@@ -331,6 +338,14 @@ static void log_unsupported_ioctl(unsigned long cmd)
+ gemu_log(" '%c' %3d %lu\n", (char)IOCGROUP(cmd), (int)(cmd & 0xff), IOCPARM_LEN(cmd));
+ }
+
++static abi_long do_ioctl_unsupported(__unused const IOCTLEntry *ie,
++ __unused uint8_t *buf_temp, __unused int fd,
++ __unused abi_long cmd, __unused abi_long arg)
++{
++
++ return -TARGET_ENXIO;
++}
++
+ abi_long do_bsd_ioctl(int fd, abi_long cmd, abi_long arg)
+ {
+ const IOCTLEntry *ie;
+diff --git a/bsd-user/freebsd/os-ioctl-cmds.h b/bsd-user/freebsd/os-ioctl-cmds.h
+index 0129f9e..f10d560 100644
+--- a/bsd-user/freebsd/os-ioctl-cmds.h
++++ b/bsd-user/freebsd/os-ioctl-cmds.h
+@@ -47,3 +47,6 @@ IOCTL(FIONWRITE, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(FIONSPACE, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(FIOSEEKDATA, IOC_RW, MK_PTR(TYPE_ULONG))
+ IOCTL(FIOSEEKHOLE, IOC_RW, MK_PTR(TYPE_ULONG))
++
++/* crypto/cryptodev.h */
++IOCTL_SPECIAL(CRIOGET, IOC_RW, do_ioctl_unsupported, TYPE_INT)
+diff --git a/bsd-user/freebsd/os-ioctl-cryptodev.h b/bsd-user/freebsd/os-ioctl-cryptodev.h
+new file mode 100644
+index 0000000..bb0d90f
+--- /dev/null
++++ b/bsd-user/freebsd/os-ioctl-cryptodev.h
+@@ -0,0 +1,85 @@
++/*
++ * FreeBSD cryptodev definitions for ioctl(2) emulation
++ *
++ * Copyright (c) 2014 Stacey D. Son
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, see <http://www.gnu.org/licenses/>.
++ */
++#ifndef _IOCTL_CRYPTODEV_H_
++#define _IOCTL_CRYPTODEV_H_
++
++/* see opencrypto/cryptodev.h */
++
++struct target_session_op {
++ u_int32_t cipher;
++ u_int32_t mac;
++
++ u_int32_t keylen;
++ abi_ulong key;
++ int32_t mackeylen;
++ abi_ulong mackey;
++
++ u_int32_t ses;
++};
++
++
++struct target_session2_op {
++ u_int32_t cipher;
++ u_int32_t mac;
++
++ u_int32_t keylen;
++ abi_ulong key;
++ int32_t mackeylen;
++ abi_ulong mackey;
++
++ u_int32_t ses;
++ int32_t crid;
++ int pad[4];
++};
++
++struct target_crypt_find_op {
++ int crid;
++ char name[32];
++};
++
++struct target_crparam {
++ abi_ulong crp_p;
++ u_int crp_nbits;
++};
++
++#define TARGET_CRK_MAXPARAM 8
++
++struct target_crypt_kop {
++ u_int crk_op;
++ u_int crk_status;
++ u_short crk_iparams;
++ u_short crk_oparams;
++ u_int crk_crid;
++ struct target_crparam crk_param[TARGET_CRK_MAXPARAM];
++};
++
++#define TARGET_CRIOGET TARGET_IOWR('c', 100, u_int32_t)
++#define TARGET_CRIOASYMFEAT TARGET_CIOCASYMFEAT
++#define TARGET_CRIOFINDDEV TARGET_CIOCFINDDEV
++
++#define TARGET_CIOCGSESSION TARGET_IOWR('c', 101, struct target_session_op)
++#define TARGET_CIOCFSESSION TARGET_IOW('c', 102, u_int32_t)
++#define TARGET_CIOCCRYPT TARGET_IOWR('c', 103, struct target_crypt_op)
++#define TARGET_CIOCKEY TARGET_IOWR('c', 104, struct target_crypt_kop)
++#define TARGET_CIOCASYMFEAT TARGET_IOR('c', 105, u_int32_t)
++#define TARGET_CIOCGSESSION2 TARGET_IOWR('c', 106, struct target_session2_op)
++#define TARGET_CIOCKEY2 TARGET_IOWR('c', 107, struct target_crypt_kop)
++#define TARGET_CIOCFINDDEV TARGET_IOWR('c', 108, struct target_crypt_find_op)
++
++#endif /* !_IOCTL_CRYPTODEV_H_ */
diff --git a/emulators/qemu-devel/files/extra-patch-f4319eb1a3a8393930570f061bdac6abe007b2bb b/emulators/qemu-devel/files/extra-patch-f4319eb1a3a8393930570f061bdac6abe007b2bb
new file mode 100644
index 000000000000..f374c4be66e7
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-f4319eb1a3a8393930570f061bdac6abe007b2bb
@@ -0,0 +1,56 @@
+From f4319eb1a3a8393930570f061bdac6abe007b2bb Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Tue, 2 Dec 2014 01:23:34 +0000
+Subject: [PATCH] Add missing setresgid(2) and setresuid(2) system call
+ handlers.
+
+---
+ bsd-user/bsd-proc.h | 12 +++++++++---
+ bsd-user/syscall.c | 8 ++++++++
+ 2 files changed, 17 insertions(+), 3 deletions(-)
+
+diff --git a/bsd-user/bsd-proc.h b/bsd-user/bsd-proc.h
+index 85dff61..459d321 100644
+--- a/bsd-user/bsd-proc.h
++++ b/bsd-user/bsd-proc.h
+@@ -303,12 +303,18 @@ static inline abi_long do_bsd_setregid(abi_long arg1, abi_long arg2)
+ return get_errno(setregid(arg1, arg2));
+ }
+
++/* setresgid(2) */
++static inline abi_long do_bsd_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
++{
++
++ return get_errno(setresgid(rgid, egid, sgid));
++}
++
+ /* setresuid(2) */
+-static inline abi_long do_bsd_setresuid(abi_long arg1, abi_long arg2,
+- abi_long arg3)
++static inline abi_long do_bsd_setresuid(uid_t ruid, uid_t euid, uid_t suid)
+ {
+
+- return get_errno(setresuid(arg1, arg2, arg3));
++ return get_errno(setresuid(ruid, euid, suid));
+ }
+
+ /* getresuid(2) */
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index 0e090f4..0a1e294 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -298,6 +298,14 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_bsd_getresgid(arg1, arg2, arg3);
+ break;
+
++ case TARGET_FREEBSD_NR_setresuid: /* setresuid(2) */
++ ret = do_bsd_setresuid(arg1, arg2, arg3);
++ break;
++
++ case TARGET_FREEBSD_NR_setresgid: /* setresgid(2) */
++ ret = do_bsd_setresgid(arg1, arg2, arg3);
++ break;
++
+ case TARGET_FREEBSD_NR_getsid: /* getsid(2) */
+ ret = do_bsd_getsid(arg1);
+ break;