target-mips: Add synci instruction test
PATCH 1/2 target-mips: Add synci instruction test
Save code with sw and raise synci. The saved code should be raise.
If the code raised, log 'test passed'.
If the code not raised, log 'test failed, the copied instruction not run'. Other cases, log 'unhandled'.
The test should log 'test passed'.
--- tests/tcg/mips/mips64/Makefile | 54 ++++++++ tests/tcg/mips/mips64/head.S | 16 +++ tests/tcg/mips/mips64/io.h | 22 +++ tests/tcg/mips/mips64/mips_boot.lds | 31 +++++ tests/tcg/mips/mips64/printf.c | 266 ++++++++++++++++++++++++++++++++++++ tests/tcg/mips/mips64/synci.c | 32 +++++ 6 files changed, 421 insertions(+) create mode 100644 tests/tcg/mips/mips64/Makefile create mode 100644 tests/tcg/mips/mips64/head.S create mode 100644 tests/tcg/mips/mips64/io.h create mode 100644 tests/tcg/mips/mips64/mips_boot.lds create mode 100644 tests/tcg/mips/mips64/printf.c create mode 100644 tests/tcg/mips/mips64/synci.c
tests/tcg/mips/mips64/Makefile new file +54 -0
@@ -0,0 +1,54 @@ +CROSS_COMPILE ?= mips64el-unknown-linux-gnu- + +SIM = qemu-system-mips64el +SIMFLAGS = -nographic -cpu mips64r2-generic -kernel + +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +RANLIB = $(CROSS_COMPILE)ranlib +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump + +VECTORS_OBJ ?= ./head.o ./printf.o + +HEAD_FLAGS ?= -nostdinc -mabi=64 -G 0 -mno-abicalls -fno-pic -pipe \ + -msoft-float -march=mips64 -Wa,-mips64 -Wa,--trap \ + -msym32 -DKBUILD_64BIT_SYM32 -I./ + +CFLAGS ?= -nostdinc -mabi=64 -G 0 -mno-abicalls -fno-pic -fno-builtin \ + -pipe -march=mips64r2 -mgp64 -mdspr2 -static -Wa,--trap -msym32 \ + -DKBUILD_64BIT_SYM32 -I./ + +LDFLAGS = -T./mips_boot.lds -L./ +FLAGS = -nostdlib -mabi=64 -march=mips64r2 -mgp64 -mdspr2 + +TESTCASES = synci.tst + +all: build + +head.o : head.S + $(Q)$(CC) $(HEAD_FLAGS) -D"STACK_TOP=0xffffffff80200000" -c $< -o $@ + +%.o : %.S + $(CC) $(CFLAGS) -c $< -o $@ + +%.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + +%.tst: %.o $(VECTORS_OBJ) + $(CC) $(VECTORS_OBJ) $(FLAGS) $(LDFLAGS) $< -o $@ + +build: $(VECTORS_OBJ) $(MIPSSOC_LIB) $(TESTCASES) + +check: $(VECTORS_OBJ) $(MIPSSOC_LIB) $(TESTCASES) + @for case in $(TESTCASES); do \ + echo $(SIM) $(SIMFLAGS) ./$$case; \ + $(SIM) $(SIMFLAGS) ./$$case & (sleep 1; killall $(SIM)); \ + done + +clean: + $(Q)rm -f *.o *.tst *.a
tests/tcg/mips/mips64/head.S new file +16 -0
@@ -0,0 +1,16 @@ +/* + * Startup Code for MIPS64 CPU-core + * + */ +.text +.globl _start +.align 4 +_start: + ori $2, $2, 0xffff + sll $2, $2, 16 + ori $2, $2, 0xffff + mtc0 $2, $12, 0 + jal main + +end: + b end
tests/tcg/mips/mips64/io.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef _ASM_IO_H +#define _ASM_IO_H +extern int printf (const char *fmt, ...); +extern unsigned long get_ticks (void ); + +#define _read (source) \ +({ unsigned long __res; \ + __asm__ __volatile__( \ + "mfc0\t%0, " #source "\n\t" \ + : "=r" (__res)); \ + __res; \ +}) + +#define __read (source) \ +({ unsigned long __res; \ + __asm__ __volatile__( \ + "move\t%0, " #source "\n\t" \ + : "=r" (__res)); \ + __res; \ +}) + +#endif
tests/tcg/mips/mips64/mips_boot.lds new file +31 -0
@@ -0,0 +1,31 @@ +OUTPUT_ARCH(mips) +SECTIONS +{ + . = 0xffffffff80100000; + . = ALIGN((1 << 13)); + .text : + { + *(.text) + *(.rodata) + *(.rodata.*) + } + + __init_begin = .; + . = ALIGN((1 << 12)); + .init.text : AT(ADDR(.init.text) - 0) + { + *(.init.text) + } + .init.data : AT(ADDR(.init.data) - 0) + { + *(.init.data) + } + . = ALIGN((1 << 12)); + __init_end = .; + + . = ALIGN((1 << 13)); + .data : + { + *(.data) + } +}
tests/tcg/mips/mips64/printf.c new file +266 -0
266 lines not on this page · raw message
tests/tcg/mips/mips64/synci.c new file +32 -0
@@ -0,0 +1,32 @@ +#include "io.h" + +int main () +{ +unsigned long addr, tmp, result =0 ; +unsigned int addi =0x21ef0001 ;/* addi $15, $15, 1 */ + + __asm + ("move %1, $15\n\t" +"move $15, $0\n\t" +"dla %0, 1f\n\t" +"sw %3, 0(%0)\n\t" +"synci 0(%0)\n\t" +"nop\n\t" +"1:\n\t" +"nop\n\t" +"move %2, $15\n\t" +"move $15, %1\n\t" + :"+r" (addr),"+r" (tmp),"=r" (result) + :"r" (addi) + ); + +if (result ==0 ) { +printf ("test failed, the copied instruction not run.\n" ); + }else if (result ==1 ) { +printf ("test passed\n" ); + }else { +printf ("unhandled\n" ); + } + +return 0 ; +}
Signature · 1 line
1.8.1.2
PATCH 2/2 target-mips/translate.c: Update OPC_SYNCI
Update OPC_SYNCI with BS_STOP, in order to handle the instructions which saved in the same TB of the store instruction.
--- target-mips/translate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target-mips/translate.c +3 -1
@@ -15334,7 +15334,9 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx)break ;case OPC_SYNCI :check_insn (ctx,ISA_MIPS32R2 ); -/* Treat as NOP. */ +/* Break the TB to be able to sync copied instructions +immediately */ + ctx->bstate =BS_STOP ;break ;case OPC_BPOSGE32 :/* MIPS DSP branch */ #if defined(TARGET_MIPS64 )
Signature · 1 line
1.8.1.2
Re: [Qemu-devel] [PATCH 2/2] target-mips/translate.c: Update OPC_SYNCI
Note that there is a microMIPS version of SYNCI, it would be even better if you could update it as well.
Best Regards,
Yongbok Kim
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dongxue Zhang
Sent: Tuesday, July 29, 2014 2:48 PM
To: [email protected]
Cc: [email protected]; Dongxue Zhang; [email protected]
Subject: [Qemu-devel] [PATCH 2/2] target-mips/translate.c: Update OPC_SYNCI
Update OPC_SYNCI with BS_STOP, in order to handle the instructions which saved in the same TB of the store instruction.
--- target-mips/translate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target-mips/translate.c +3 -1
@@ -15334,7 +15334,9 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx)break ;case OPC_SYNCI :check_insn (ctx,ISA_MIPS32R2 ); -/* Treat as NOP. */ +/* Break the TB to be able to sync copied instructions +immediately */ + ctx->bstate =BS_STOP ;break ;case OPC_BPOSGE32 :/* MIPS DSP branch */ #if defined(TARGET_MIPS64 )
Signature · 1 line
1.8.1.2
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dongxue Zhang
Sent: Tuesday, July 29, 2014 2:48 PM
To: [email protected]
Cc: [email protected]; Dongxue Zhang; [email protected]
Subject: [Qemu-devel] [PATCH 1/2] target-mips: Add synci instruction test
Save code with sw and raise synci. The saved code should be raise.
If the code raised, log 'test passed'.
If the code not raised, log 'test failed, the copied instruction not run'. Other cases, log 'unhandled'.
The test should log 'test passed'.
--- tests/tcg/mips/mips64/Makefile | 54 ++++++++ tests/tcg/mips/mips64/head.S | 16 +++ tests/tcg/mips/mips64/io.h | 22 +++ tests/tcg/mips/mips64/mips_boot.lds | 31 +++++ tests/tcg/mips/mips64/printf.c | 266 ++++++++++++++++++++++++++++++++++++ tests/tcg/mips/mips64/synci.c | 32 +++++ 6 files changed, 421 insertions(+) create mode 100644 tests/tcg/mips/mips64/Makefile create mode 100644 tests/tcg/mips/mips64/head.S create mode 100644 tests/tcg/mips/mips64/io.h create mode 100644 tests/tcg/mips/mips64/mips_boot.lds create mode 100644 tests/tcg/mips/mips64/printf.c create mode 100644 tests/tcg/mips/mips64/synci.c
tests/tcg/mips/mips64/Makefile new file +54 -0
@@ -0,0 +1,54 @@ +CROSS_COMPILE ?= mips64el-unknown-linux-gnu- + +SIM = qemu-system-mips64el +SIMFLAGS = -nographic -cpu mips64r2-generic -kernel + +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +RANLIB = $(CROSS_COMPILE)ranlib +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump + +VECTORS_OBJ ?= ./head.o ./printf.o + +HEAD_FLAGS ?= -nostdinc -mabi=64 -G 0 -mno-abicalls -fno-pic -pipe \ + -msoft-float -march=mips64 -Wa,-mips64 -Wa,--trap \ + -msym32 -DKBUILD_64BIT_SYM32 -I./ + +CFLAGS ?= -nostdinc -mabi=64 -G 0 -mno-abicalls -fno-pic -fno-builtin \ + -pipe -march=mips64r2 -mgp64 -mdspr2 -static -Wa,--trap -msym32 \ + -DKBUILD_64BIT_SYM32 -I./ + +LDFLAGS = -T./mips_boot.lds -L./ +FLAGS = -nostdlib -mabi=64 -march=mips64r2 -mgp64 -mdspr2 + +TESTCASES = synci.tst + +all: build + +head.o : head.S + $(Q)$(CC) $(HEAD_FLAGS) -D"STACK_TOP=0xffffffff80200000" -c $< -o $@ + +%.o : %.S + $(CC) $(CFLAGS) -c $< -o $@ + +%.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + +%.tst: %.o $(VECTORS_OBJ) + $(CC) $(VECTORS_OBJ) $(FLAGS) $(LDFLAGS) $< -o $@ + +build: $(VECTORS_OBJ) $(MIPSSOC_LIB) $(TESTCASES) + +check: $(VECTORS_OBJ) $(MIPSSOC_LIB) $(TESTCASES) + @for case in $(TESTCASES); do \ + echo $(SIM) $(SIMFLAGS) ./$$case; \ + $(SIM) $(SIMFLAGS) ./$$case & (sleep 1; killall $(SIM)); \ + done + +clean: + $(Q)rm -f *.o *.tst *.a
tests/tcg/mips/mips64/head.S new file +16 -0
@@ -0,0 +1,16 @@ +/* + * Startup Code for MIPS64 CPU-core + * + */ +.text +.globl _start +.align 4 +_start: + ori $2, $2, 0xffff + sll $2, $2, 16 + ori $2, $2, 0xffff + mtc0 $2, $12, 0 + jal main + +end: + b end
tests/tcg/mips/mips64/io.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef _ASM_IO_H +#define _ASM_IO_H +extern int printf (const char *fmt, ...); +extern unsigned long get_ticks (void ); + +#define _read (source) \ +({ unsigned long __res; \ + __asm__ __volatile__( \ + "mfc0\t%0, " #source "\n\t" \ + : "=r" (__res)); \ + __res; \ +}) + +#define __read (source) \ +({ unsigned long __res; \ + __asm__ __volatile__( \ + "move\t%0, " #source "\n\t" \ + : "=r" (__res)); \ + __res; \ +}) + +#endif
tests/tcg/mips/mips64/mips_boot.lds new file +31 -0
@@ -0,0 +1,31 @@ +OUTPUT_ARCH(mips) +SECTIONS +{ + . = 0xffffffff80100000; + . = ALIGN((1 << 13)); + .text : + { + *(.text) + *(.rodata) + *(.rodata.*) + } + + __init_begin = .; + . = ALIGN((1 << 12)); + .init.text : AT(ADDR(.init.text) - 0) + { + *(.init.text) + } + .init.data : AT(ADDR(.init.data) - 0) + { + *(.init.data) + } + . = ALIGN((1 << 12)); + __init_end = .; + + . = ALIGN((1 << 13)); + .data : + { + *(.data) + } +}
tests/tcg/mips/mips64/printf.c new file +266 -0
266 lines not on this page · raw message
tests/tcg/mips/mips64/synci.c new file +32 -0
@@ -0,0 +1,32 @@ +#include "io.h" + +int main () +{ +unsigned long addr, tmp, result =0 ; +unsigned int addi =0x21ef0001 ;/* addi $15, $15, 1 */ + + __asm + ("move %1, $15\n\t" +"move $15, $0\n\t" +"dla %0, 1f\n\t" +"sw %3, 0(%0)\n\t" +"synci 0(%0)\n\t" +"nop\n\t" +"1:\n\t" +"nop\n\t" +"move %2, $15\n\t" +"move $15, %1\n\t" + :"+r" (addr),"+r" (tmp),"=r" (result) + :"r" (addi) + ); + +if (result ==0 ) { +printf ("test failed, the copied instruction not run.\n" ); + }else if (result ==1 ) { +printf ("test passed\n" ); + }else { +printf ("unhandled\n" ); + } + +return 0 ; +}
Signature · 1 line
1.8.1.2