qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: Matheus Ferst <matheus.ferst@eldorado.org.br>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: clg@kaod.org, david@gibson.dropbear.id.au, groug@kaod.org
Subject: Re: [PATCH v3] target/ppc: check tb_env != 0 before printing TBU/TBL/DECR
Date: Thu, 14 Jul 2022 17:48:46 -0300	[thread overview]
Message-ID: <323fa299-dfd0-357d-12e0-61ca31f52d4d@gmail.com> (raw)
In-Reply-To: <20220714172343.80539-1-matheus.ferst@eldorado.org.br>



On 7/14/22 14:23, Matheus Ferst wrote:
> When using "-machine none", env->tb_env is not allocated, causing the
> segmentation fault reported in issue #85 (launchpad bug #811683). To
> avoid this problem, check if the pointer != NULL before calling the
> methods to print TBU/TBL/DECR.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/85
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> v3:
>    - Only check env->tb_env in softmmu, linux-user get timebase from
>      elsewhere. Also, try to make the qemu_fprintf call more readable.
>    - Link to v2: https://lists.gnu.org/archive/html/qemu-ppc/2022-07/msg00193.html
> ---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>


And queued.


Daniel

>   target/ppc/cpu_init.c | 18 ++++++++----------
>   target/ppc/monitor.c  |  9 +++++++++
>   2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 86ad28466a..313c8bb300 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -7476,17 +7476,15 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int flags)
>                    "%08x iidx %d didx %d\n",
>                    env->msr, env->spr[SPR_HID0], env->hflags,
>                    cpu_mmu_index(env, true), cpu_mmu_index(env, false));
> -#if !defined(NO_TIMER_DUMP)
> -    qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
>   #if !defined(CONFIG_USER_ONLY)
> -                 " DECR " TARGET_FMT_lu
> -#endif
> -                 "\n",
> -                 cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
> -#if !defined(CONFIG_USER_ONLY)
> -                 , cpu_ppc_load_decr(env)
> -#endif
> -        );
> +    if (env->tb_env) {
> +        qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
> +                     " DECR " TARGET_FMT_lu "\n", cpu_ppc_load_tbu(env),
> +                     cpu_ppc_load_tbl(env), cpu_ppc_load_decr(env));
> +    }
> +#else
> +    qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 "\n", cpu_ppc_load_tbu(env),
> +                 cpu_ppc_load_tbl(env));
>   #endif
>       for (i = 0; i < 32; i++) {
>           if ((i & (RGPL - 1)) == 0) {
> diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c
> index 0b805ef6e9..8250b1304e 100644
> --- a/target/ppc/monitor.c
> +++ b/target/ppc/monitor.c
> @@ -55,6 +55,9 @@ static target_long monitor_get_decr(Monitor *mon, const struct MonitorDef *md,
>                                       int val)
>   {
>       CPUArchState *env = mon_get_cpu_env(mon);
> +    if (!env->tb_env) {
> +        return 0;
> +    }
>       return cpu_ppc_load_decr(env);
>   }
>   
> @@ -62,6 +65,9 @@ static target_long monitor_get_tbu(Monitor *mon, const struct MonitorDef *md,
>                                      int val)
>   {
>       CPUArchState *env = mon_get_cpu_env(mon);
> +    if (!env->tb_env) {
> +        return 0;
> +    }
>       return cpu_ppc_load_tbu(env);
>   }
>   
> @@ -69,6 +75,9 @@ static target_long monitor_get_tbl(Monitor *mon, const struct MonitorDef *md,
>                                      int val)
>   {
>       CPUArchState *env = mon_get_cpu_env(mon);
> +    if (!env->tb_env) {
> +        return 0;
> +    }
>       return cpu_ppc_load_tbl(env);
>   }
>   


      reply	other threads:[~2022-07-14 20:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 17:23 [PATCH v3] target/ppc: check tb_env != 0 before printing TBU/TBL/DECR Matheus Ferst
2022-07-14 20:48 ` Daniel Henrique Barboza [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=323fa299-dfd0-357d-12e0-61ca31f52d4d@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=matheus.ferst@eldorado.org.br \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).