MIPS64 user mode emulation in QEMU with Cavium specific instruction support
v2 cover MIPS64 user mode emulation in QEMU with Cavium specific instruction support
From: Khansa Butt <[email protected]>
This is the team work of Ehsan-ul-Haq, Abdul Qadeer, Abdul Waheed, Khansa Butt from HPCN Lab KICS UET Lahore.
v1 contains:
* SEQI related changes specified by Richard Henderson
* Fix issues related to coding style, typos and misleading comments
* Cavium specific change in set_thread_area syscall has been removed
* as it corresponds to modified libc and kernel.
This Patch series add support of MIPS64 user mode emulation in QEMU. Along with we implemented Cavium specific instructions which We will use in SME (in sysem mode emulation of Octeon processor)
If you have any objection regarding the Implementation of Cavium instructions please read following notes.
Notes
*****
The detail of some instructions are as follows
1)seq rd,rs,rt
seq-->rd = 1 if rs = rt
is equivalent to
xor rd,rs,rt
sltiu rd,rd,1
2)exts rt,rs,p,lenm1
rt = sign-extend(rs<p+lenm1:p>,lenm1)
Quoted 1 line
From reference manual of Cavium Networks
"Bit locations p + lenm1 to p are extracted from rs and the result is written into the lowest bits of destination register rt. The remaining bits in rt are a sign-extension of the most-significant bit of the bit field (i.e. rt<63:lenm1> are all duplicates of the source-register bit rs<p+lenm1>)." so we can't use any of 8,16 or 32 bit sign extention tcg function. To sign extend according to msb of bit field we have our own implementation
3)dmul rd,rs,rt
This instruction is included in gen_arith() because it is three operand double word multiply instruction.
configure | 1 + default-configs/mips64-linux-user.mak | 1 + linux-user/main.c | 21 ++- linux-user/mips64/syscall.h | 2 + linux-user/signal.c | 438 ++++++++++++++++++++++++++++++++- mips-dis.c | 53 ++++ target-mips/cpu.h | 7 + target-mips/helper.h | 5 + target-mips/machine.c | 12 + target-mips/mips-defs.h | 2 + target-mips/op_helper.c | 73 ++++++ target-mips/translate.c | 431 ++++++++++++++++++++++++++++++++- target-mips/translate_init.c | 24 ++ 13 files changed, 1050 insertions(+), 20 deletions(-) create mode 100644 default-configs/mips64-linux-user.mak
Signature · 1 line
1.7.3.4
PATCH v2 1/6 linux-user:Support for MIPS64 user mode emulation in QEMU
From: Khansa Butt <[email protected]>
--- configure | 1 + default-configs/mips64-linux-user.mak | 1 + linux-user/main.c | 21 +++++++++++++++++++-- linux-user/mips64/syscall.h | 2 ++ linux-user/signal.c | 2 -- 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 default-configs/mips64-linux-user.mak
configure +1 -0
@@ -891,6 +891,7 @@ m68k-linux-user \ microblaze-linux-user \ microblazeel-linux-user \ mips-linux-user \ +mips64-linux-user \ mipsel-linux-user \ ppc-linux-user \ ppc64-linux-user \
default-configs/mips64-linux-user.mak new file +1 -0
@@ -0,0 +1 @@ +# Default configuration for mips64-linux-user
linux-user/main.c +19 -2
@@ -2068,7 +2068,8 @@ static int do_store_exclusive(CPUMIPSState *env)void cpu_loop (CPUMIPSState *env) {target_siginfo_t info; -int trapnr, ret; +int trapnr; +abi_long ret;unsigned int syscall_num;for (;;) {
@@ -2077,8 +2078,23 @@ void cpu_loop(CPUMIPSState *env)cpu_exec_end (env);switch (trapnr) {case EXCP_SYSCALL : - syscall_num = env->active_tc.gpr[2 ] -4000 ; env->active_tc.PC +=4 ; +#if defined(TARGET_MIPS64 ) + syscall_num = env->active_tc.gpr[2 ] -5000 ; +/* MIPS64 has eight argument registers so there is +* no need to get arguments from stack +*/ + ret =do_syscall (env, env->active_tc.gpr[2 ], + env->active_tc.gpr[4 ], + env->active_tc.gpr[5 ], + env->active_tc.gpr[6 ], + env->active_tc.gpr[7 ], + env->active_tc.gpr[8 ], + env->active_tc.gpr[9 ], + env->active_tc.gpr[10 ], + env->active_tc.gpr[11 ]); +#else + syscall_num = env->active_tc.gpr[2 ] -4000 ;if (syscall_num >=sizeof (mips_syscall_args)) { ret = -TARGET_ENOSYS ; }else {
@@ -2105,6 +2121,7 @@ void cpu_loop(CPUMIPSState *env) env->active_tc.gpr[7 ], arg5, arg6, arg7, arg8); } +#endif if (ret == -TARGET_QEMU_ESIGRETURN ) {/* Returning from a successful sigreturn syscall. Avoid clobbering register state. */
linux-user/mips64/syscall.h +2 -0
@@ -218,4 +218,6 @@ struct target_pt_regs { +#define TARGET_QEMU_ESIGRETURN 255 +#define UNAME_MACHINE "mips64"
linux-user/signal.c +0 -2
@@ -2415,8 +2415,6 @@ void sparc64_get_context(CPUSPARCState *env)#endif #elif defined(TARGET_ABI_MIPSN64) -# warning signal handling not implemented -static void setup_frame (int sig,struct target_sigaction *ka,target_sigset_t *set,CPUState *env) {
Signature · 1 line
1.7.3.4
PATCH v2 2/6 target-mips:enabling of 64 bit user mode and floating point operations
In reply to [email protected]From: Khansa Butt <[email protected]>
--- target-mips/translate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
target-mips/translate.c +2 -0
@@ -12779,6 +12779,8 @@ void cpu_reset (CPUMIPSState *env) env->hflags |=MIPS_HFLAG_FPU ; }#ifdef TARGET_MIPS64 + env->hflags |=MIPS_HFLAG_UX ; + env->active_fpu.fcr0 = env->cpu_model->CP1_fcr0;if (env->active_fpu.fcr0 & (1 <<FCR0_F64 )) { env->hflags |=MIPS_HFLAG_F64 ; }
Signature · 1 line
1.7.3.4