From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Sergey Fedorov <serge.fdrv@gmail.com>,
qemu-arm@nongnu.org, patches@linaro.org
Subject: [Qemu-devel] [PATCH 00/11] target-arm: clean up cpsr_write mode changing
Date: Mon, 15 Feb 2016 17:22:46 +0000 [thread overview]
Message-ID: <1455556977-3644-1-git-send-email-peter.maydell@linaro.org> (raw)
This patchset cleans up our usage of cpsr_write() somewhat, and in
particular its handling of attempts to change the MODE bits.
Currently we use cpsr_write() for multiple purposes:
* writes on inbound migration and sync with KVM, where we want
a raw "just write these bits" and have to actively mess with
uncached_cpsr before the write to avoid it doing a register bank
switch
* writes caused by guest instructions MSR and CPS
* writes caused by guest 32-bit exception returns
* a few other things like the gdb stub
However the required handling differs for these different cases;
in particular the set of conditions which are architecturally
defined to be an illegal mode switch is different for writes due
to MSR/CPS versus writes due to exception returns.
To fix this we add an extra argument to cpsr_write() which is an
enum indicating what kind of write is being performed.
This allows us to drop the irritating "manually write the mode
bits before the call" code in KVM/migration (and fix a bug where
we missed this out in 32-bit KVM!). We can also add the various
missing conditions:
* changes to hyp mode
* changes from hyp mode by MSR/CPS
* changes to Mon from Secure EL1
* changes from Mon to NS PL1 when HCR.TGE is set
Finally we can implement the v8 behaviour of setting PSTATE.IL
for illegal mode changes.
The series also fixes the behaviour of attempted illegal mode
changes from the gdb stub -- we ignore them, but don't set PSTATE.IL.
(Previously we had a slightly weird setup where we would permit
changes from User to the PL1 modes but not to Mon.) Not permitting
illegal changes from the debugger:
* means we don't have to consider weird "transition is possible
but only for the debugger" corner cases
* matches the behaviour of a JTAG debugger doing external debug
on real ARM hardware, where architecturally the illegal state
transitions are enforced
PS: we don't currently implement the PSTATE.IL "any attempt to
execute an insn will UNDEF" behaviour, but it would not be hard
to add.
thanks
-- PMM
Peter Maydell (11):
target-arm: Give CPSR setting on 32-bit exception return its own
helper
target-arm: Add write_type argument to cpsr_write()
target-arm: Raw CPSR writes should skip checks and bank switching
linux-user: Use restrictive mask when calling cpsr_write()
target-arm: In cpsr_write() ignore mode switches from User mode
target-arm: Add comment about not implementing NSACR.RFR
target-arm: Add Hyp mode checks to bad_mode_switch()
target-arm: Forbid mode switch to Mon from Secure EL1
target-arm: In v8, make illegal AArch32 mode changes set PSTATE.IL
target-arm: Make mode switches from Hyp via CPS and MRS illegal
target-arm: Make Monitor->NS PL1 mode changes illegal if HCR.TGE is 1
linux-user/arm/nwfpe/fpa11.h | 2 +-
linux-user/main.c | 7 +++---
linux-user/signal.c | 4 ++--
target-arm/cpu.h | 13 +++++++++--
target-arm/gdbstub.c | 2 +-
target-arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++--------
target-arm/helper.h | 1 +
target-arm/kvm32.c | 2 +-
target-arm/kvm64.c | 3 +--
target-arm/machine.c | 4 +---
target-arm/op_helper.c | 15 +++++++++---
target-arm/translate.c | 6 ++---
12 files changed, 83 insertions(+), 30 deletions(-)
--
1.9.1
next reply other threads:[~2016-02-15 17:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 17:22 Peter Maydell [this message]
2016-02-15 17:22 ` [Qemu-arm] [PATCH 01/11] target-arm: Give CPSR setting on 32-bit exception return its own helper Peter Maydell
2016-02-18 17:41 ` Sergey Fedorov
2016-02-15 17:22 ` [Qemu-arm] [PATCH 02/11] target-arm: Add write_type argument to cpsr_write() Peter Maydell
2016-02-18 17:42 ` Sergey Fedorov
2016-02-15 17:22 ` [Qemu-devel] [PATCH 03/11] target-arm: Raw CPSR writes should skip checks and bank switching Peter Maydell
2016-02-18 17:42 ` [Qemu-arm] " Sergey Fedorov
2016-02-15 17:22 ` [Qemu-arm] [PATCH 04/11] linux-user: Use restrictive mask when calling cpsr_write() Peter Maydell
2016-02-18 17:42 ` [Qemu-devel] " Sergey Fedorov
2016-02-15 17:22 ` [Qemu-arm] [PATCH 05/11] target-arm: In cpsr_write() ignore mode switches from User mode Peter Maydell
2016-02-18 17:43 ` Sergey Fedorov
2016-02-15 17:22 ` [Qemu-devel] [PATCH 06/11] target-arm: Add comment about not implementing NSACR.RFR Peter Maydell
2016-02-18 17:43 ` Sergey Fedorov
2016-02-15 17:22 ` [Qemu-devel] [PATCH 07/11] target-arm: Add Hyp mode checks to bad_mode_switch() Peter Maydell
2016-02-18 17:43 ` [Qemu-arm] " Sergey Fedorov
2016-02-15 17:22 ` [Qemu-devel] [PATCH 08/11] target-arm: Forbid mode switch to Mon from Secure EL1 Peter Maydell
2016-02-18 17:43 ` [Qemu-arm] " Sergey Fedorov
2016-02-15 17:22 ` [Qemu-devel] [PATCH 09/11] target-arm: In v8, make illegal AArch32 mode changes set PSTATE.IL Peter Maydell
2016-02-18 17:44 ` [Qemu-arm] " Sergey Fedorov
2016-02-15 17:22 ` [Qemu-devel] [PATCH 10/11] target-arm: Make mode switches from Hyp via CPS and MRS illegal Peter Maydell
2016-02-18 17:44 ` [Qemu-arm] " Sergey Fedorov
2016-02-15 17:22 ` [Qemu-devel] [PATCH 11/11] target-arm: Make Monitor->NS PL1 mode changes illegal if HCR.TGE is 1 Peter Maydell
2016-02-18 17:44 ` [Qemu-arm] " Sergey Fedorov
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=1455556977-3644-1-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=edgar.iglesias@gmail.com \
--cc=patches@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=serge.fdrv@gmail.com \
/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).