* pstate_read/write ignores nRW field that is kept in env->aarch64
@ 2020-10-06 11:36 ivan.i.kulagin
2020-10-06 12:28 ` Peter Maydell
0 siblings, 1 reply; 2+ messages in thread
From: ivan.i.kulagin @ 2020-10-06 11:36 UTC (permalink / raw)
To: qemu-arm; +Cc: peter.maydell
Hello!
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.
static inline uint32_t pstate_read(CPUARMState *env)
{
int ZF;
ZF = (env->ZF == 0);
return (env->NF & 0x80000000) | (ZF << 30)
| (env->CF << 29) | ((env->VF & 0x80000000) >> 3)
| env->pstate | env->daif | (env->btype << 10);
}
Best regards, Ivan.
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: pstate_read/write ignores nRW field that is kept in env->aarch64
2020-10-06 11:36 pstate_read/write ignores nRW field that is kept in env->aarch64 ivan.i.kulagin
@ 2020-10-06 12:28 ` Peter Maydell
0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2020-10-06 12:28 UTC (permalink / raw)
To: ivan.i.kulagin; +Cc: qemu-arm
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;
/* ... */
cpsr_write(...);
/* ... */
} else {
env->aarch64 = 1;
/* ... */
pstate_write(...);
/* ... */
}
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.
thanks
-- PMM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-06 14:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-06 11:36 pstate_read/write ignores nRW field that is kept in env->aarch64 ivan.i.kulagin
2020-10-06 12:28 ` Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.