From: Fabiano Rosas <farosas@suse.de>
To: Harsh Prateek Bora <harshpb@linux.ibm.com>, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org, danielhb413@gmail.com
Subject: Re: [PATCH 4/5] ppc: spapr: cleanup spapr_exit_nested() with helper routines.
Date: Fri, 14 Apr 2023 08:58:35 -0300 [thread overview]
Message-ID: <87pm86isk4.fsf@suse.de> (raw)
In-Reply-To: <20230331065344.112341-5-harshpb@linux.ibm.com>
Harsh Prateek Bora <harshpb@linux.ibm.com> writes:
> Currently, in spapr_exit_nested(), it does a lot of register state
> restoring from ptregs/hvstate after mapping each of those before
> restoring the L1 host state. This patch breaks down those set of ops
> to respective helper routines for better code readability/maintenance.
>
> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> ---
> hw/ppc/spapr_hcall.c | 132 +++++++++++++++++++++++++------------------
> 1 file changed, 78 insertions(+), 54 deletions(-)
>
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index a77b4c9076..ed3a21471d 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -1701,36 +1701,23 @@ static target_ulong h_enter_nested(PowerPCCPU *cpu,
> return env->gpr[3];
> }
>
> -void spapr_exit_nested(PowerPCCPU *cpu, int excp)
> +static void restore_hvstate_from_env(struct kvmppc_hv_guest_state *hvstate,
> + CPUPPCState *env, int excp)
> {
> - CPUState *cs = CPU(cpu);
> - CPUPPCState *env = &cpu->env;
> - SpaprCpuState *spapr_cpu = spapr_cpu_state(cpu);
> - target_ulong r3_return = env->excp_vectors[excp]; /* hcall return value */
> - target_ulong hv_ptr = spapr_cpu->nested_host_state->gpr[4];
> - target_ulong regs_ptr = spapr_cpu->nested_host_state->gpr[5];
> - struct kvmppc_hv_guest_state *hvstate;
> - struct kvmppc_pt_regs *regs;
> - hwaddr len;
> -
> - assert(spapr_cpu->in_nested);
> -
> - cpu_ppc_hdecr_exit(env);
> -
> - len = sizeof(*hvstate);
> - hvstate = address_space_map(CPU(cpu)->as, hv_ptr, &len, true,
> - MEMTXATTRS_UNSPECIFIED);
> - if (len != sizeof(*hvstate)) {
> - address_space_unmap(CPU(cpu)->as, hvstate, len, 0, true);
> - r3_return = H_PARAMETER;
> - goto out_restore_l1;
> - }
> -
> - hvstate->cfar = env->cfar;
> - hvstate->lpcr = env->spr[SPR_LPCR];
> - hvstate->pcr = env->spr[SPR_PCR];
> - hvstate->dpdes = env->spr[SPR_DPDES];
> - hvstate->hfscr = env->spr[SPR_HFSCR];
> + hvstate->cfar = env->cfar;
> + hvstate->lpcr = env->spr[SPR_LPCR];
> + hvstate->pcr = env->spr[SPR_PCR];
> + hvstate->dpdes = env->spr[SPR_DPDES];
> + hvstate->hfscr = env->spr[SPR_HFSCR];
> + /* HEIR should be implemented for HV mode and saved here. */
> + hvstate->srr0 = env->spr[SPR_SRR0];
> + hvstate->srr1 = env->spr[SPR_SRR1];
> + hvstate->sprg[0] = env->spr[SPR_SPRG0];
> + hvstate->sprg[1] = env->spr[SPR_SPRG1];
> + hvstate->sprg[2] = env->spr[SPR_SPRG2];
> + hvstate->sprg[3] = env->spr[SPR_SPRG3];
> + hvstate->pidr = env->spr[SPR_BOOKS_PID];
> + hvstate->ppr = env->spr[SPR_PPR];
Just leave these lines as they were. Let's avoid spending time
discussing code style. Also, the patch became harder to review by having
these unrelated changes interspersed.
next prev parent reply other threads:[~2023-04-14 11:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-31 6:53 [PATCH 0/5] Cleanup [h_enter|spapr_exit]_nested routines Harsh Prateek Bora
2023-03-31 6:53 ` [PATCH 1/5] ppc: spapr: cleanup cr get/store with helper routines Harsh Prateek Bora
2023-04-14 11:40 ` Fabiano Rosas
2023-04-17 6:54 ` Harsh Prateek Bora
2023-03-31 6:53 ` [PATCH 2/5] ppc: spapr: cleanup h_enter_nested() " Harsh Prateek Bora
2023-04-14 11:53 ` Fabiano Rosas
2023-04-17 7:02 ` Harsh Prateek Bora
2023-03-31 6:53 ` [PATCH 3/5] ppc: spapr: assert early rather late in h_enter_nested() Harsh Prateek Bora
2023-04-14 11:55 ` Fabiano Rosas
2023-04-17 7:15 ` Harsh Prateek Bora
2023-03-31 6:53 ` [PATCH 4/5] ppc: spapr: cleanup spapr_exit_nested() with helper routines Harsh Prateek Bora
2023-04-14 11:58 ` Fabiano Rosas [this message]
2023-04-17 7:17 ` Harsh Prateek Bora
2023-03-31 6:53 ` [PATCH 5/5] MAINTAINERS: Adding myself in the list for ppc/spapr Harsh Prateek Bora
2023-04-14 11:57 ` Daniel Henrique Barboza
2023-04-17 7:21 ` Harsh Prateek Bora
2023-03-31 10:39 ` [PATCH 0/5] Cleanup [h_enter|spapr_exit]_nested routines Cédric Le Goater
2023-03-31 11:06 ` Daniel Henrique Barboza
2023-04-11 4:15 ` Harsh Prateek Bora
2023-04-14 12:04 ` Fabiano Rosas
2023-04-17 7:21 ` Harsh Prateek Bora
2023-04-17 10:10 ` Cédric Le Goater
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=87pm86isk4.fsf@suse.de \
--to=farosas@suse.de \
--cc=danielhb413@gmail.com \
--cc=harshpb@linux.ibm.com \
--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).