[Qemu-devel] [PATCH] target/ppc: Initialize lazy_tlb_flush correctly

David Gibson posted 1 patch 7 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180320020345.24930-1-david@gibson.dropbear.id.au
Test checkpatch passed
Test docker-build@min-glib passed
Test docker-mingw@fedora passed
Test docker-quick@centos6 passed
Test s390x passed
target/ppc/translate.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
[Qemu-devel] [PATCH] target/ppc: Initialize lazy_tlb_flush correctly
Posted by David Gibson 7 years, 7 months ago
ppc_tr_init_disas_context() correctly sets lazy_tlb_flush to true on
certain CPU models.  However, it leaves it uninitialized, instead of
setting it to false on all others.

It wasn't caught before now because we didn't have examples in the tests
that exercised this path.  However it can now be caught using clang's
undefined behaviour sanitizer and the sam460ex board.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 target/ppc/translate.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 218665b408..3457d29f8e 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -7237,10 +7237,9 @@ static int ppc_tr_init_disas_context(DisasContextBase *dcbase,
     ctx->sf_mode = msr_is_64bit(env, env->msr);
     ctx->has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
 #endif
-    if (env->mmu_model == POWERPC_MMU_32B ||
-        env->mmu_model == POWERPC_MMU_601 ||
-        (env->mmu_model & POWERPC_MMU_64B))
-            ctx->lazy_tlb_flush = true;
+    ctx->lazy_tlb_flush = env->mmu_model == POWERPC_MMU_32B
+        || env->mmu_model == POWERPC_MMU_601
+        || (env->mmu_model & POWERPC_MMU_64B);
 
     ctx->fpu_enabled = !!msr_fp;
     if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
-- 
2.14.3


Re: [Qemu-devel] [PATCH] target/ppc: Initialize lazy_tlb_flush correctly
Posted by Thomas Huth 7 years, 7 months ago
On 20.03.2018 03:03, David Gibson wrote:
> ppc_tr_init_disas_context() correctly sets lazy_tlb_flush to true on
> certain CPU models.  However, it leaves it uninitialized, instead of
> setting it to false on all others.
> 
> It wasn't caught before now because we didn't have examples in the tests
> that exercised this path.  However it can now be caught using clang's
> undefined behaviour sanitizer and the sam460ex board.
> 
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  target/ppc/translate.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index 218665b408..3457d29f8e 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -7237,10 +7237,9 @@ static int ppc_tr_init_disas_context(DisasContextBase *dcbase,
>      ctx->sf_mode = msr_is_64bit(env, env->msr);
>      ctx->has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
>  #endif
> -    if (env->mmu_model == POWERPC_MMU_32B ||
> -        env->mmu_model == POWERPC_MMU_601 ||
> -        (env->mmu_model & POWERPC_MMU_64B))
> -            ctx->lazy_tlb_flush = true;
> +    ctx->lazy_tlb_flush = env->mmu_model == POWERPC_MMU_32B
> +        || env->mmu_model == POWERPC_MMU_601
> +        || (env->mmu_model & POWERPC_MMU_64B);
>  
>      ctx->fpu_enabled = !!msr_fp;
>      if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

Re: [Qemu-devel] [PATCH] target/ppc: Initialize lazy_tlb_flush correctly
Posted by Greg Kurz 7 years, 7 months ago
On Tue, 20 Mar 2018 13:03:45 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> ppc_tr_init_disas_context() correctly sets lazy_tlb_flush to true on
> certain CPU models.  However, it leaves it uninitialized, instead of
> setting it to false on all others.
> 
> It wasn't caught before now because we didn't have examples in the tests
> that exercised this path.  However it can now be caught using clang's
> undefined behaviour sanitizer and the sam460ex board.
> 
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  target/ppc/translate.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index 218665b408..3457d29f8e 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -7237,10 +7237,9 @@ static int ppc_tr_init_disas_context(DisasContextBase *dcbase,
>      ctx->sf_mode = msr_is_64bit(env, env->msr);
>      ctx->has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
>  #endif
> -    if (env->mmu_model == POWERPC_MMU_32B ||
> -        env->mmu_model == POWERPC_MMU_601 ||
> -        (env->mmu_model & POWERPC_MMU_64B))
> -            ctx->lazy_tlb_flush = true;
> +    ctx->lazy_tlb_flush = env->mmu_model == POWERPC_MMU_32B
> +        || env->mmu_model == POWERPC_MMU_601
> +        || (env->mmu_model & POWERPC_MMU_64B);
>  
>      ctx->fpu_enabled = !!msr_fp;
>      if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)