From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Harsh Prateek Bora" <harshpb@linux.ibm.com>, <qemu-ppc@nongnu.org>
Cc: <qemu-devel@nongnu.org>
Subject: Re: [RFC PATCH 2/4] spapr: Add a nested state struct
Date: Sat, 13 May 2023 13:27:58 +1000 [thread overview]
Message-ID: <CSKTWZM7SQV2.1RQ5UDVUCVHVU@wheely> (raw)
In-Reply-To: <516d30a6-a329-d361-feea-e616e936dd41@linux.ibm.com>
On Fri May 5, 2023 at 8:54 PM AEST, Harsh Prateek Bora wrote:
> <correcting my email in CC>
>
> On 5/3/23 06:09, Nicholas Piggin wrote:
> > @@ -1593,12 +1713,14 @@ static target_ulong h_enter_nested(PowerPCCPU *cpu,
> > return H_PARAMETER;
> > }
> >
> > - spapr_cpu->nested_host_state = g_try_new(CPUPPCState, 1);
> > + spapr_cpu->nested_host_state = g_try_new(struct nested_ppc_state, 1);
> > if (!spapr_cpu->nested_host_state) {
> > return H_NO_MEM;
> > }
> >
> > - memcpy(spapr_cpu->nested_host_state, env, sizeof(CPUPPCState));
> > + assert(env->spr[SPR_LPIDR] == 0);
> > + assert(env->spr[SPR_DPDES] == 0);
> > + nested_save_state(spapr_cpu->nested_host_state, cpu);
> >
> Ideally, we may want to save entire env for L1 host, while switching to
> L2 rather than keeping a subset of it for 2 reasons:
> - keeping enitre L1 env ensures it remains untouched by L2 during L2
> execution (shouldnt allow L2 to modify remaining L1 env bits unexpectedly)
It doesn't because you need to restore it, and you can't just restore
all. Making it symmetrical and saving what you restore is better. It's
a pretty nasty layering violation to memcpy the whole CPUPPCState too,
conceptually.
I prefer that we have to think about each bit of state that is changed
and how we deal with it -- I'd not be at all surprised if there are bits
that are wrong as is, e.g., in interrupt handling.
> - I see some of the registers are retained only for L1 (so, ca, ov32,
> ca32, etc) but not for L2 (got missed in nested_load_state helper in
> this patch), are they not really needed anymore? Previous patch
> introduced one of them though.
I'm not sure. those fields aren't registers as such, but mirror in some
values from regisers. I didn't think I got it wrong but I'll double
check.
Thanks,
Nick
next prev parent reply other threads:[~2023-05-13 3:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 0:39 [RFC PATCH 0/4] spapr: clean up nested hv Nicholas Piggin
2023-05-03 0:39 ` [RFC PATCH 1/4] spapr: H_ENTER_NESTED should restore host XER ca field Nicholas Piggin
2023-05-05 10:20 ` Harsh Prateek Bora
2023-05-03 0:39 ` [RFC PATCH 2/4] spapr: Add a nested state struct Nicholas Piggin
2023-05-05 10:54 ` Harsh Prateek Bora
2023-05-13 3:27 ` Nicholas Piggin [this message]
2023-05-03 0:39 ` [RFC PATCH 3/4] spapr: load and store l2 state with helper functions Nicholas Piggin
2023-05-05 11:03 ` Harsh Prateek Bora
2023-05-13 3:30 ` Nicholas Piggin
2023-05-03 0:39 ` [RFC PATCH 4/4] spapr: Move spapr nested HV to a new file Nicholas Piggin
2023-05-05 11:09 ` Harsh Prateek Bora
2023-05-13 3:32 ` Nicholas Piggin
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=CSKTWZM7SQV2.1RQ5UDVUCVHVU@wheely \
--to=npiggin@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).