[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pstate_read/write ignores nRW field that is kept in env->aarch64

From: Peter Maydell
Subject: Re: pstate_read/write ignores nRW field that is kept in env->aarch64
Date: Tue, 6 Oct 2020 13:28:20 +0100

On Tue, 6 Oct 2020 at 12:36, <ivan.i.kulagin@gmail.com> wrote:
> Could you please explain me why in pstate_read and pstate_write
> the nRW bit is ignored?
> The comment in CPUState says that nRW (also known as M[4]) is kept,
> inverted, in env->aarch64,
> but the value returned by pstate_read doesn't contain this bit.

That's because pstate_read() is in general only used from
contexts where the CPU is known to be in AArch64 state
and so that bit is always zero. AArch32 state code instead
uses cpsr_read(). Similarly for pstate_write(), it is only
used in cases where we're in (or switching to) AArch64
state, and the calling code generally handles the "flip
the env->aarch64 flag" part itself -- see for instance
the exception_return handling in helper-a64.c, which does

 if (!return_to_aa64) {
     env->aarch64 = 0;
     /* ... */
     /* ... */
 } else {
     env->aarch64 = 1;
     /* ... */
     /* ... */

This is because switching between AArch32 and AArch64 is
complicated (among other things you need to sync the state
to or from the 32-bit and 64-bit views of the general
purpose registers in env->regs[] and env->xregs[]). It
never happens just as a side-effect of a pstate_write():
you always know you're making the switch and are doing
a lot of other things at the same time.

-- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]