* [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS()
@ 2016-10-12 22:35 Michael Walle
2016-10-12 22:35 ` [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS() Michael Walle
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Michael Walle @ 2016-10-12 22:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Walle
Be consistent with the reference manual.
Signed-off-by: Michael Walle <michael@walle.cc>
---
target-lm32/translate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
index dc64cc6..fa8416a 100644
--- a/target-lm32/translate.c
+++ b/target-lm32/translate.c
@@ -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:
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS()
2016-10-12 22:35 [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Michael Walle
@ 2016-10-12 22:35 ` Michael Walle
2016-10-13 10:36 ` Peter Maydell
2016-10-12 22:35 ` [Qemu-devel] [PATCH 3/4] lm32: milkymist-tmu2: fix integer overflow Michael Walle
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Michael Walle @ 2016-10-12 22:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Walle
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.
Signed-off-by: Michael Walle <michael@walle.cc>
---
target-lm32/translate.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
index fa8416a..792637f 100644
--- a/target-lm32/translate.c
+++ b/target-lm32/translate.c
@@ -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))
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 3/4] lm32: milkymist-tmu2: fix integer overflow
2016-10-12 22:35 [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Michael Walle
2016-10-12 22:35 ` [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS() Michael Walle
@ 2016-10-12 22:35 ` Michael Walle
2016-10-13 10:37 ` Peter Maydell
2016-10-12 22:35 ` [Qemu-devel] [PATCH 4/4] target-lm32: rewrite gen_compare() Michael Walle
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Michael Walle @ 2016-10-12 22:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, 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 <michael@walle.cc>
---
hw/display/milkymist-tmu2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/display/milkymist-tmu2.c b/hw/display/milkymist-tmu2.c
index 9c00184..5c666f9 100644
--- a/hw/display/milkymist-tmu2.c
+++ b/hw/display/milkymist-tmu2.c
@@ -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);
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 4/4] target-lm32: rewrite gen_compare()
2016-10-12 22:35 [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Michael Walle
2016-10-12 22:35 ` [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS() Michael Walle
2016-10-12 22:35 ` [Qemu-devel] [PATCH 3/4] lm32: milkymist-tmu2: fix integer overflow Michael Walle
@ 2016-10-12 22:35 ` Michael Walle
2016-10-13 10:37 ` Peter Maydell
2016-10-13 10:35 ` [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Peter Maydell
2016-10-15 12:39 ` Michael Tokarev
4 siblings, 1 reply; 9+ messages in thread
From: Michael Walle @ 2016-10-12 22:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, 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 <michael@walle.cc>
---
target-lm32/translate.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
index 792637f..842af63 100644
--- a/target-lm32/translate.c
+++ b/target-lm32/translate.c
@@ -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]);
}
}
--
2.1.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS()
2016-10-12 22:35 [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Michael Walle
` (2 preceding siblings ...)
2016-10-12 22:35 ` [Qemu-devel] [PATCH 4/4] target-lm32: rewrite gen_compare() Michael Walle
@ 2016-10-13 10:35 ` Peter Maydell
2016-10-15 12:39 ` Michael Tokarev
4 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2016-10-13 10:35 UTC (permalink / raw)
To: Michael Walle; +Cc: QEMU Developers, QEMU Trivial
On 12 October 2016 at 23:35, Michael Walle <michael@walle.cc> wrote:
> Be consistent with the reference manual.
>
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
> target-lm32/translate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target-lm32/translate.c b/target-lm32/translate.c
> index dc64cc6..fa8416a 100644
> --- a/target-lm32/translate.c
> +++ b/target-lm32/translate.c
> @@ -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:
> --
> 2.1.4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS()
2016-10-12 22:35 ` [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS() Michael Walle
@ 2016-10-13 10:36 ` Peter Maydell
0 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2016-10-13 10:36 UTC (permalink / raw)
To: Michael Walle; +Cc: QEMU Developers, QEMU Trivial
On 12 October 2016 at 23:35, Michael Walle <michael@walle.cc> wrote:
> 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.
>
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
> target-lm32/translate.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/target-lm32/translate.c b/target-lm32/translate.c
> index fa8416a..792637f 100644
> --- a/target-lm32/translate.c
> +++ b/target-lm32/translate.c
> @@ -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))
> --
> 2.1.4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 3/4] lm32: milkymist-tmu2: fix integer overflow
2016-10-12 22:35 ` [Qemu-devel] [PATCH 3/4] lm32: milkymist-tmu2: fix integer overflow Michael Walle
@ 2016-10-13 10:37 ` Peter Maydell
0 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2016-10-13 10:37 UTC (permalink / raw)
To: Michael Walle; +Cc: QEMU Developers, QEMU Trivial
On 12 October 2016 at 23:35, Michael Walle <michael@walle.cc> wrote:
> 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 <michael@walle.cc>
> ---
> hw/display/milkymist-tmu2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/display/milkymist-tmu2.c b/hw/display/milkymist-tmu2.c
> index 9c00184..5c666f9 100644
> --- a/hw/display/milkymist-tmu2.c
> +++ b/hw/display/milkymist-tmu2.c
> @@ -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);
> --
> 2.1.4
>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 4/4] target-lm32: rewrite gen_compare()
2016-10-12 22:35 ` [Qemu-devel] [PATCH 4/4] target-lm32: rewrite gen_compare() Michael Walle
@ 2016-10-13 10:37 ` Peter Maydell
0 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2016-10-13 10:37 UTC (permalink / raw)
To: Michael Walle; +Cc: QEMU Developers, QEMU Trivial
On 12 October 2016 at 23:35, Michael Walle <michael@walle.cc> wrote:
> 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 <michael@walle.cc>
> ---
> target-lm32/translate.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/target-lm32/translate.c b/target-lm32/translate.c
> index 792637f..842af63 100644
> --- a/target-lm32/translate.c
> +++ b/target-lm32/translate.c
> @@ -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]);
> }
> }
>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS()
2016-10-12 22:35 [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Michael Walle
` (3 preceding siblings ...)
2016-10-13 10:35 ` [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Peter Maydell
@ 2016-10-15 12:39 ` Michael Tokarev
4 siblings, 0 replies; 9+ messages in thread
From: Michael Tokarev @ 2016-10-15 12:39 UTC (permalink / raw)
To: Michael Walle, qemu-devel; +Cc: qemu-trivial, Peter Maydell
Applied all 4 to -trivial. With some digging around :)
Thanks,
/mjt
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-10-15 12:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12 22:35 [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Michael Walle
2016-10-12 22:35 ` [Qemu-devel] [PATCH 2/4] target-lm32: disable asm logging via LOG_DIS() Michael Walle
2016-10-13 10:36 ` Peter Maydell
2016-10-12 22:35 ` [Qemu-devel] [PATCH 3/4] lm32: milkymist-tmu2: fix integer overflow Michael Walle
2016-10-13 10:37 ` Peter Maydell
2016-10-12 22:35 ` [Qemu-devel] [PATCH 4/4] target-lm32: rewrite gen_compare() Michael Walle
2016-10-13 10:37 ` Peter Maydell
2016-10-13 10:35 ` [Qemu-devel] [PATCH 1/4] target-lm32: swap operand of wcsr in LOG_DIS() Peter Maydell
2016-10-15 12:39 ` Michael Tokarev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.