From: Samuel Ortiz <sameo@linux.intel.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
qemu-arm <qemu-arm@nongnu.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 03/13] target: arm: Move all v7m helpers into their own file
Date: Tue, 27 Nov 2018 12:45:14 +0100 [thread overview]
Message-ID: <20181127114514.GB4393@caravaggio> (raw)
In-Reply-To: <CAFEAcA98so9yyJN=qAhD=Kr6pi1xxfrxt28atqZ8ATVJYXTaMg@mail.gmail.com>
Hi Peter,
On Tue, Nov 20, 2018 at 01:54:08PM +0000, Peter Maydell wrote:
> On 13 November 2018 at 16:52, Samuel Ortiz <sameo@linux.intel.com> wrote:
> > In preparation for supporting TCG disablement on ARM, we move all TCG
> > related v7m helpers and APIs into their own file (m_helper.c for all
> > v*-m helpers).
> > arm_v7m_cpu_do_interrupt pulls a large number of static functions
> > out of helper.c into m_helper.c because it is TCG dependent.
> >
> > Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > Reviewed-by: Robert Bradford <robert.bradford@intel.com>
> > ---
> > target/arm/internals.h | 37 +
> > target/arm/helper.c | 2209 +++-----------------------------------
> > target/arm/m_helper.c | 1892 ++++++++++++++++++++++++++++++++
> > target/arm/Makefile.objs | 2 +-
> > 4 files changed, 2086 insertions(+), 2054 deletions(-)
> > create mode 100644 target/arm/m_helper.c
>
> > +/* Function used to synchronize QEMU's AArch64 register set with AArch32
> > + * register set. This is necessary when switching between AArch32 and AArch64
> > + * execution state.
> > + */
> > +void aarch64_sync_32_to_64(CPUARMState *env)
> > {
> > - uint32_t new_ss_msp, new_ss_psp;
> > + int i;
> > + uint32_t mode = env->uncached_cpsr & CPSR_M;
> >
> > - if (env->v7m.secure == new_secstate) {
> > - return;
> > + /* We can blanket copy R[0:7] to X[0:7] */
> > + for (i = 0; i < 8; i++) {
> > + env->xregs[i] = env->regs[i];
> > }
> >
> > - /* All the banked state is accessed by looking at env->v7m.secure
> > - * except for the stack pointer; rearrange the SP appropriately.
> > + /* Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12.
> > + * Otherwise, they come from the banked user regs.
> > */
> > - new_ss_msp = env->v7m.other_ss_msp;
> > - new_ss_psp = env->v7m.other_ss_psp;
> > -
> > - if (v7m_using_psp(env)) {
> > - env->v7m.other_ss_psp = env->regs[13];
> > - env->v7m.other_ss_msp = env->v7m.other_sp;
> > - } else {
> > - env->v7m.other_ss_msp = env->regs[13];
> > - env->v7m.other_ss_psp = env->v7m.other_sp;
> > - }
> > -
> > - env->v7m.secure = new_secstate;
> > -
> > - if (v7m_using_psp(env)) {
> > - env->regs[13] = new_ss_psp;
> > - env->v7m.other_sp = new_ss_msp;
> > + if (mode == ARM_CPU_MODE_FIQ) {
> > + for (i = 8; i < 13; i++) {
> > + env->xregs[i] = env->usr_regs[i - 8];
> > + }
> > } else {
> > - env->regs[13] = new_ss_msp;
> > - env->v7m.other_sp = new_ss_psp;
> > + for (i = 8; i < 13; i++) {
> > + env->xregs[i] = env->regs[i];
> > + }
> > }
> > -}
> >
> > -void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
> > -{
> > - /* Handle v7M BXNS:
> > - * - if the return value is a magic value, do exception return (like BX)
> > - * - otherwise bit 0 of the return value is the target security state
> > + /* Registers x13-x23 are the various mode SP and FP registers. Registers
> > + * r13 and r14 are only copied if we are in that mode, otherwise we copy
> > + * from the mode banked register.
> > */
> > - uint32_t min_magic;
> > -
> > - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
> > - /* Covers FNC_RETURN and EXC_RETURN magic */
> > - min_magic = FNC_RETURN_MIN_MAGIC;
> > + if (mode == ARM_CPU_MODE_USR || mode == ARM_CPU_MODE_SYS) {
> > + env->xregs[13] = env->regs[13];
> > + env->xregs[14] = env->regs[14];
> > } else {
> > - /* EXC_RETURN magic only */
> > - min_magic = EXC_RETURN_MIN_MAGIC;
> > + env->xregs[13] = env->banked_r13[bank_number(ARM_CPU_MODE_USR)];
> > + /* HYP is an exception in that it is copied from r14 */
> > + if (mode == ARM_CPU_MODE_HYP) {
> > + env->xregs[14] = env->regs[14];
> > + } else {
> > + env->xregs[14] = env->banked_r14[bank_number(ARM_CPU_MODE_USR)];
> > + }
> > }
>
> This part of the patch is a mess to read. I suspect this is a
> combination of (a) your git not being configured to use a better
> diff algorithm than the default (try "algorithm = histogram"
> in the [diff] section of your .gitconfig), and it doing an effective
> revert of 593cfa2b637b92d37 by accident.
Yes, the unintentional and partial revert made the patch messy.
I fixed that.
> It's also an absolutely enormous patch, even for a "just
> moving code" patch, which makes it hard to review even
> with diff --color-moved. Maybe it would be better in two
> pieces ("helper routines for various insns" and "exception
> handling functions" seems like a workable split).
Splitting and fixing the original patch made things much easier to read,
thanks for the suggestion. See:
https://github.com/intel/nemu/pull/167/commits/5da42ba691bc05f3311332cfb3fe6db33b456904
https://github.com/intel/nemu/pull/167/commits/43cf20ed61e8c1f77d4706e29ba54df620a5091e
Cheers,
Samuel.
next prev parent reply other threads:[~2018-11-27 11:45 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 16:52 [Qemu-devel] [PATCH 00/13] Support disabling TCG on ARM Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 01/13] target: arm: Add copyright boilerplate Samuel Ortiz
2018-11-13 16:58 ` Peter Maydell
2018-11-13 17:00 ` Philippe Mathieu-Daudé
2018-11-13 23:29 ` Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 02/13] target: arm: Remove unused headers Samuel Ortiz
2018-11-13 17:01 ` Peter Maydell
2018-11-13 18:02 ` Philippe Mathieu-Daudé
2018-11-13 18:07 ` Peter Maydell
2018-11-13 18:10 ` Philippe Mathieu-Daudé
2018-11-13 23:28 ` Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 03/13] target: arm: Move all v7m helpers into their own file Samuel Ortiz
2018-11-20 13:54 ` Peter Maydell
2018-11-20 19:26 ` Philippe Mathieu-Daudé
2018-11-27 11:45 ` Samuel Ortiz [this message]
2018-11-13 16:52 ` [Qemu-devel] [PATCH 04/13] target: arm: Move all interrupt and exception handlers " Samuel Ortiz
2018-11-20 13:45 ` Peter Maydell
2018-11-27 15:35 ` Samuel Ortiz
2018-11-27 15:46 ` Peter Maydell
2018-11-28 10:40 ` Samuel Ortiz
2018-11-28 11:39 ` Peter Maydell
2018-11-28 13:57 ` Samuel Ortiz
2018-11-28 15:00 ` Samuel Ortiz
2018-11-20 14:03 ` Peter Maydell
2018-11-13 16:52 ` [Qemu-devel] [PATCH 05/13] target: arm: Move the DC ZVA helper into op_helper Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 06/13] target: arm: Make ARM TLB filling routine static Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 07/13] target: arm: Remove the LDST headers Samuel Ortiz
2018-11-20 14:00 ` Peter Maydell
2018-11-13 16:52 ` [Qemu-devel] [PATCH 08/13] target: arm: Move all VFP helpers into their own file Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 09/13] target: arm: Move CPU state dumping routines to helper.c Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 10/13] target: arm: Move watchpoints APIs " Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 11/13] target: arm: Define TCG dependent functions when TCG is enabled Samuel Ortiz
2018-11-20 14:09 ` Peter Maydell
2018-11-13 16:52 ` [Qemu-devel] [PATCH 12/13] target: arm: Makefile cleanup Samuel Ortiz
2018-11-13 16:52 ` [Qemu-devel] [PATCH 13/13] target: arm: Do not build TCG objects when TCG is off Samuel Ortiz
2018-11-14 11:56 ` [Qemu-devel] [PATCH 00/13] Support disabling TCG on ARM no-reply
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=20181127114514.GB4393@caravaggio \
--to=sameo@linux.intel.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).