target-lm32: swap operand of wcsr in LOG_DIS()
PATCH 1/4 target-lm32: swap operand of wcsr in LOG_DIS()
Be consistent with the reference manual.
--- target-lm32/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-lm32/translate.c +1 -1
@@ -865,7 +865,7 @@ static void dec_wcsr(DisasContext *dc) {int no; -LOG_DIS ("wcsr r%d, %d\n" , dc->r1, dc->csr); +LOG_DIS ("wcsr %d, r%d\n" , dc->csr, dc->r1);switch (dc->csr) {case CSR_IE :
Signature · 1 line
2.1.4
PATCH 2/4 target-lm32: disable asm logging via LOG_DIS()
The lm32 target already has a disassembler which logs the assembly instructions with "-d in_asm". Therefore, turn of the LOG_DIS() macro to prevent logging the assembly instructions twice. Also turn the macro in a one which is always compiled to catch any errors while the macro is turned off.
--- target-lm32/translate.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
target-lm32/translate.c +8 -6
@@ -33,12 +33,14 @@#include "exec/log.h" -#define DISAS_LM32 1 -#if DISAS_LM32 -# define LOG_DIS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__) -#else -# define LOG_DIS (...) do { } while (0) -#endif +#define DISAS_LM32 0 + +#define LOG_DIS (...) \ + do { \ + if (DISAS_LM32) { \ + qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__); \ + } \ + } while (0)#define EXTRACT_FIELD (src, start, end) \ (((src) >> start) & ((1 << (end - start + 1)) - 1))
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS()
Quoted 37 lines · Michael Walle
The lm32 target already has a disassembler which logs the assembly instructions with "-d
in_asm". Therefore, turn of theLOG_DIS()macro to prevent logging the assembly instructions twice. Also turn the macro in a one which is always compiled to catch any errors while the macro is turned off.Signed-off-by Michael Walle <[email protected]>--- target-lm32/translate.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)target-lm32/translate.c +8
-7@@ -33,12 +33,14 @@#include "exec/log.h" -#define DISAS_LM32 1 -#if DISAS_LM32 -# define LOG_DIS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__) -#else -# define LOG_DIS (...) do { } while (0) -#endif +#define DISAS_LM32 0 + +#define LOG_DIS (...) \ + do { \ + if (DISAS_LM32) { \ + qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__); \ + } \ + } while (0)#define EXTRACT_FIELD (src, start, end) \ (((src) >> start) & ((1 << (end - start + 1)) - 1)) --
Quoted 1 line
2.1.4
thanks
-- PMM
PATCH 3/4 lm32: milkymist-tmu2: fix integer overflow
In reply to Michael WalleDon't truncate the multiplication and do a 64 bit one instead because because the result is stored in a 64 bit variable.
Spotted by coverity, CID 1167561.
--- hw/display/milkymist-tmu2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/milkymist-tmu2.c +1 -1
@@ -213,7 +213,7 @@ static void tmu2_start(MilkymistTMU2State *s)/* Read the QEMU source framebuffer into an OpenGL texture */ glGenTextures (1 , &texture);glBindTexture (GL_TEXTURE_2D , texture); - fb_len =2 *s->regs[R_TEXHRES ]*s->regs[R_TEXVRES ]; + fb_len =2ULL * s->regs[R_TEXHRES ] * s->regs[R_TEXVRES ]; fb =cpu_physical_memory_map (s->regs[R_TEXFBUF ], &fb_len,0 );if (fb ==NULL ) {glDeleteTextures (1 , &texture);
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 3/4] lm32: milkymist-tmu2: fix integer overflow
Quoted 24 lines · Michael Walle
Don't truncate the multiplication and do a 64 bit one instead because because the result is stored in a 64 bit variable.
Spotted by coverity, CID 1167561.
Signed-off-by Michael Walle <[email protected]>--- hw/display/milkymist-tmu2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/display/milkymist-tmu2.c +1
-2@@ -213,7 +213,7 @@ static void tmu2_start(MilkymistTMU2State *s)/* Read the QEMU source framebuffer into an OpenGL texture */ glGenTextures (1 , &texture);glBindTexture (GL_TEXTURE_2D , texture); - fb_len =2 *s->regs[R_TEXHRES ]*s->regs[R_TEXVRES ]; + fb_len =2ULL * s->regs[R_TEXHRES ] * s->regs[R_TEXVRES ]; fb =cpu_physical_memory_map (s->regs[R_TEXFBUF ], &fb_len,0 );if (fb ==NULL ) {glDeleteTextures (1 , &texture); --
Quoted 2 lines
2.1.4
thanks
-- PMM
PATCH 4/4 target-lm32: rewrite gen_compare()
In reply to Michael WalleDrop the rX, rY and rZ stuff and use dc->r{0,1,2} directly. This should also fix the false positive in coverity CID 1005720.
--- target-lm32/translate.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
target-lm32/translate.c +2 -5
@@ -344,9 +344,6 @@ static void dec_calli(DisasContext *dc)static inline void gen_compare (DisasContext *dc,int cond) { -int rX = (dc->format ==OP_FMT_RR ) ? dc->r2 : dc->r1; -int rY = dc->r0; -int rZ = (dc->format ==OP_FMT_RR ) ? dc->r1 :-1 ;int i;if (dc->format ==OP_FMT_RI ) {
@@ -360,9 +357,9 @@ static inline void gen_compare(DisasContext *dc, int cond)break ; } -tcg_gen_setcondi_tl (cond, cpu_R[rX], cpu_R[rY], i); +tcg_gen_setcondi_tl (cond, cpu_R[dc->r1], cpu_R[dc->r0], i); }else { -tcg_gen_setcond_tl (cond, cpu_R[rX], cpu_R[rY], cpu_R[rZ]); +tcg_gen_setcond_tl (cond, cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); } }
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 4/4] target-lm32: rewrite gen_compare()
Quoted 24 lines · Michael Walle
Drop the rX, rY and rZ stuff and use dc->r{0,1,2} directly. This should also fix the false positive in coverity CID 1005720.
Signed-off-by Michael Walle <[email protected]>--- target-lm32/translate.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)target-lm32/translate.c +0
-3@@ -344,9 +344,6 @@ static void dec_calli(DisasContext *dc)static inline void gen_compare (DisasContext *dc,int cond) { -int rX = (dc->format ==OP_FMT_RR ) ? dc->r2 : dc->r1; -int rY = dc->r0; -int rZ = (dc->format ==OP_FMT_RR ) ? dc->r1 :-1 ;int i;if (dc->format ==OP_FMT_RI ) {@@ -360,9 +357,9 @@ static inline void gen_compare(DisasContext *dc, int cond)break ;
target-lm32/translate.c static inline void gen_compare(DisasContext *dc, int cond) · line 365
Quoted 10 lines
target-lm32/translate.c +2
-2} -tcg_gen_setcondi_tl (cond, cpu_R[rX], cpu_R[rY], i); +tcg_gen_setcondi_tl (cond, cpu_R[dc->r1], cpu_R[dc->r0], i); }else { -tcg_gen_setcond_tl (cond, cpu_R[rX], cpu_R[rY], cpu_R[rZ]); +tcg_gen_setcond_tl (cond, cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]); } }
thanks
-- PMM
Quoted 21 lines · Michael Walle
Be consistent with the reference manual.
Signed-off-by Michael Walle <[email protected]>--- target-lm32/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-lm32/translate.c +1
-2@@ -865,7 +865,7 @@ static void dec_wcsr(DisasContext *dc) {int no; -LOG_DIS ("wcsr r%d, %d\n" , dc->r1, dc->csr); +LOG_DIS ("wcsr %d, r%d\n" , dc->csr, dc->r1);switch (dc->csr) {case CSR_IE : --
Quoted 1 line
2.1.4
thanks
-- PMM
Michael Tokarev
AppliedApplied all 4 to -trivial. With some digging around :)
Thanks,
/mjt