qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: BALATON Zoltan <balaton@eik.bme.hu>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: clg@kaod.org, Greg Kurz <groug@kaod.org>
Subject: Re: [PATCH 7/7] target/ppc: Eliminate goto in mmubooke_check_tlb()
Date: Mon, 5 Jun 2023 10:37:25 -0300	[thread overview]
Message-ID: <cc967aa7-2c96-b091-cda2-7e290500e0d9@gmail.com> (raw)
In-Reply-To: <bd84d5f38af0ba2983ccd5c07635db49267c828f.1685448535.git.balaton@eik.bme.hu>



On 5/30/23 10:28, BALATON Zoltan wrote:
> Move out checking PID registers into a separate function which makes
> mmubooke_check_tlb() simpler and avoids using goto.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---

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

>   target/ppc/mmu_common.c | 40 +++++++++++++++++++++-------------------
>   1 file changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
> index bd7d7d5257..ae1db6e348 100644
> --- a/target/ppc/mmu_common.c
> +++ b/target/ppc/mmu_common.c
> @@ -601,37 +601,39 @@ static int mmu40x_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,
>       return ret;
>   }
>   
> -static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb,
> -                              hwaddr *raddr, int *prot, target_ulong address,
> -                              MMUAccessType access_type, int i)
> +static bool mmubooke_check_pid(CPUPPCState *env, ppcemb_tlb_t *tlb,
> +                               hwaddr *raddr, target_ulong addr, int i)
>   {
> -    int prot2;
> -
> -    if (ppcemb_tlb_check(env, tlb, raddr, address,
> -                         env->spr[SPR_BOOKE_PID], i)) {
> +    if (ppcemb_tlb_check(env, tlb, raddr, addr, env->spr[SPR_BOOKE_PID], i)) {
>           if (!env->nb_pids) {
>               /* Extend the physical address to 36 bits */
>               *raddr |= (uint64_t)(tlb->RPN & 0xF) << 32;
>           }
> -        goto found_tlb;
> +        return true;
> +    } else if (!env->nb_pids) {
> +        return false;
>       }
> -
>       if (env->spr[SPR_BOOKE_PID1] &&
> -        ppcemb_tlb_check(env, tlb, raddr, address,
> -                         env->spr[SPR_BOOKE_PID1], i)) {
> -        goto found_tlb;
> +        ppcemb_tlb_check(env, tlb, raddr, addr, env->spr[SPR_BOOKE_PID1], i)) {
> +        return true;
>       }
> -
>       if (env->spr[SPR_BOOKE_PID2] &&
> -        ppcemb_tlb_check(env, tlb, raddr, address,
> -                         env->spr[SPR_BOOKE_PID2], i)) {
> -        goto found_tlb;
> +        ppcemb_tlb_check(env, tlb, raddr, addr, env->spr[SPR_BOOKE_PID2], i)) {
> +        return true;
>       }
> +    return false;
> +}
>   
> -     qemu_log_mask(CPU_LOG_MMU, "%s: TLB entry not found\n", __func__);
> -    return -1;
> +static int mmubooke_check_tlb(CPUPPCState *env, ppcemb_tlb_t *tlb,
> +                              hwaddr *raddr, int *prot, target_ulong address,
> +                              MMUAccessType access_type, int i)
> +{
> +    int prot2;
>   
> -found_tlb:
> +    if (!mmubooke_check_pid(env, tlb, raddr, address, i)) {
> +        qemu_log_mask(CPU_LOG_MMU, "%s: TLB entry not found\n", __func__);
> +        return -1;
> +    }
>   
>       if (FIELD_EX64(env->msr, MSR, PR)) {
>           prot2 = tlb->prot & 0xF;


  reply	other threads:[~2023-06-05 13:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 13:28 [PATCH 0/7] Embedded PPC misc clean up and optimisation BALATON Zoltan
2023-05-30 13:28 ` [PATCH 1/7] target/ppc: Remove single use function BALATON Zoltan
2023-06-01  8:39   ` Cédric Le Goater
2023-05-30 13:28 ` [PATCH 2/7] target/ppc: Remove "ext" parameter of ppcemb_tlb_check() BALATON Zoltan
2023-06-01  8:39   ` Cédric Le Goater
2023-05-30 13:28 ` [PATCH 3/7] target/ppc: Move ppcemb_tlb_search() to mmu_common.c BALATON Zoltan
2023-06-01  8:39   ` Cédric Le Goater
2023-05-30 13:28 ` [PATCH 4/7] target/ppc: Remove some unneded line breaks BALATON Zoltan
2023-06-01  8:39   ` Cédric Le Goater
2023-05-30 13:28 ` [PATCH 5/7] target/ppc: Simplify ppcemb_tlb_search() BALATON Zoltan
2023-06-01  8:39   ` Cédric Le Goater
2023-05-30 13:28 ` [PATCH 6/7] target/ppc: Change ppcemb_tlb_check() to return bool BALATON Zoltan
2023-06-01  8:39   ` Cédric Le Goater
2023-05-30 13:28 ` [PATCH 7/7] target/ppc: Eliminate goto in mmubooke_check_tlb() BALATON Zoltan
2023-06-05 13:37   ` Daniel Henrique Barboza [this message]
2023-06-05 13:37 ` [PATCH 0/7] Embedded PPC misc clean up and optimisation Daniel Henrique Barboza

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=cc967aa7-2c96-b091-cda2-7e290500e0d9@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --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).