All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails
@ 2021-05-05 16:10 Philippe Mathieu-Daudé
  2021-05-05 16:52 ` Richard Henderson
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-05 16:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Philippe Mathieu-Daudé, Yoshinori Sato

If the get_physical_address() call fails, the SH4 get_phys_page_debug()
handler returns an uninitialized address. Instead return -1, which
correspond to "no page found" (see cpu_get_phys_page_debug() doc
string).

This fixes a warning emitted when building with CFLAGS=-O3
(using GCC 10.2.1 20201125):

  target/sh4/helper.c: In function ‘superh_cpu_get_phys_page_debug’:
  target/sh4/helper.c:446:12: warning: ‘physical’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    446 |     return physical;
        |            ^~~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/sh4/helper.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/target/sh4/helper.c b/target/sh4/helper.c
index bd8e034f174..2d622081e85 100644
--- a/target/sh4/helper.c
+++ b/target/sh4/helper.c
@@ -441,9 +441,12 @@ hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
     target_ulong physical;
     int prot;
 
-    get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD);
+    if (get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD)
+            == MMU_OK) {
+        return physical;
+    }
 
-    return physical;
+    return -1;
 }
 
 void cpu_load_tlb(CPUSH4State * env)
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails
  2021-05-05 16:10 [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails Philippe Mathieu-Daudé
@ 2021-05-05 16:52 ` Richard Henderson
  2021-05-06  8:03 ` Yoshinori Sato
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2021-05-05 16:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Yoshinori Sato

On 5/5/21 9:10 AM, Philippe Mathieu-Daudé wrote:
> If the get_physical_address() call fails, the SH4 get_phys_page_debug()
> handler returns an uninitialized address. Instead return -1, which
> correspond to "no page found" (see cpu_get_phys_page_debug() doc
> string).
> 
> This fixes a warning emitted when building with CFLAGS=-O3
> (using GCC 10.2.1 20201125):
> 
>    target/sh4/helper.c: In function ‘superh_cpu_get_phys_page_debug’:
>    target/sh4/helper.c:446:12: warning: ‘physical’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>      446 |     return physical;
>          |            ^~~~~~~~
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/sh4/helper.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails
  2021-05-05 16:10 [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails Philippe Mathieu-Daudé
  2021-05-05 16:52 ` Richard Henderson
@ 2021-05-06  8:03 ` Yoshinori Sato
  2021-05-13 17:01 ` Laurent Vivier
  2021-05-13 17:05 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 5+ messages in thread
From: Yoshinori Sato @ 2021-05-06  8:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Richard Henderson, qemu-devel

On Thu, 06 May 2021 01:10:46 +0900,
Philippe Mathieu-Daudé wrote:
> 
> If the get_physical_address() call fails, the SH4 get_phys_page_debug()
> handler returns an uninitialized address. Instead return -1, which
> correspond to "no page found" (see cpu_get_phys_page_debug() doc
> string).
> 
> This fixes a warning emitted when building with CFLAGS=-O3
> (using GCC 10.2.1 20201125):
> 
>   target/sh4/helper.c: In function ‘superh_cpu_get_phys_page_debug’:
>   target/sh4/helper.c:446:12: warning: ‘physical’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>     446 |     return physical;
>         |            ^~~~~~~~
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/sh4/helper.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/target/sh4/helper.c b/target/sh4/helper.c
> index bd8e034f174..2d622081e85 100644
> --- a/target/sh4/helper.c
> +++ b/target/sh4/helper.c
> @@ -441,9 +441,12 @@ hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
>      target_ulong physical;
>      int prot;
>  
> -    get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD);
> +    if (get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD)
> +            == MMU_OK) {
> +        return physical;
> +    }
>  
> -    return physical;
> +    return -1;
>  }
>  
>  void cpu_load_tlb(CPUSH4State * env)
> -- 
> 2.26.3
> 
> 

Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>

-- 
Yosinori Sato

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails
  2021-05-05 16:10 [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails Philippe Mathieu-Daudé
  2021-05-05 16:52 ` Richard Henderson
  2021-05-06  8:03 ` Yoshinori Sato
@ 2021-05-13 17:01 ` Laurent Vivier
  2021-05-13 17:05 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2021-05-13 17:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: qemu-trivial, Richard Henderson, Yoshinori Sato

Le 05/05/2021 à 18:10, Philippe Mathieu-Daudé a écrit :
> If the get_physical_address() call fails, the SH4 get_phys_page_debug()
> handler returns an uninitialized address. Instead return -1, which
> correspond to "no page found" (see cpu_get_phys_page_debug() doc
> string).
> 
> This fixes a warning emitted when building with CFLAGS=-O3
> (using GCC 10.2.1 20201125):
> 
>   target/sh4/helper.c: In function ‘superh_cpu_get_phys_page_debug’:
>   target/sh4/helper.c:446:12: warning: ‘physical’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>     446 |     return physical;
>         |            ^~~~~~~~
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/sh4/helper.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/target/sh4/helper.c b/target/sh4/helper.c
> index bd8e034f174..2d622081e85 100644
> --- a/target/sh4/helper.c
> +++ b/target/sh4/helper.c
> @@ -441,9 +441,12 @@ hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
>      target_ulong physical;
>      int prot;
>  
> -    get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD);
> +    if (get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD)
> +            == MMU_OK) {
> +        return physical;
> +    }
>  
> -    return physical;
> +    return -1;
>  }
>  
>  void cpu_load_tlb(CPUSH4State * env)
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails
  2021-05-05 16:10 [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-05-13 17:01 ` Laurent Vivier
@ 2021-05-13 17:05 ` Philippe Mathieu-Daudé
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-13 17:05 UTC (permalink / raw)
  To: qemu-devel, QEMU Trivial; +Cc: Richard Henderson, Yoshinori Sato

Cc'ing qemu-trivial@

On 5/5/21 6:10 PM, Philippe Mathieu-Daudé wrote:
> If the get_physical_address() call fails, the SH4 get_phys_page_debug()
> handler returns an uninitialized address. Instead return -1, which
> correspond to "no page found" (see cpu_get_phys_page_debug() doc
> string).
> 
> This fixes a warning emitted when building with CFLAGS=-O3
> (using GCC 10.2.1 20201125):
> 
>   target/sh4/helper.c: In function ‘superh_cpu_get_phys_page_debug’:
>   target/sh4/helper.c:446:12: warning: ‘physical’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>     446 |     return physical;
>         |            ^~~~~~~~
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/sh4/helper.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/target/sh4/helper.c b/target/sh4/helper.c
> index bd8e034f174..2d622081e85 100644
> --- a/target/sh4/helper.c
> +++ b/target/sh4/helper.c
> @@ -441,9 +441,12 @@ hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
>      target_ulong physical;
>      int prot;
>  
> -    get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD);
> +    if (get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD)
> +            == MMU_OK) {
> +        return physical;
> +    }
>  
> -    return physical;
> +    return -1;
>  }
>  
>  void cpu_load_tlb(CPUSH4State * env)
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-13 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 16:10 [PATCH] target/sh4: Return error if CPUClass::get_phys_page_debug() fails Philippe Mathieu-Daudé
2021-05-05 16:52 ` Richard Henderson
2021-05-06  8:03 ` Yoshinori Sato
2021-05-13 17:01 ` Laurent Vivier
2021-05-13 17:05 ` Philippe Mathieu-Daudé

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.