qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Thomas Huth <thuth@redhat.com>,
	qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH 2/4] target/arm: Move cortex-m related functions to new file v7m.c
Date: Tue, 24 Sep 2019 13:02:11 +0200	[thread overview]
Message-ID: <5b967a2a-e1db-9a9f-7590-fc6905354f7a@redhat.com> (raw)
In-Reply-To: <8585b93b-e239-829b-d634-b89941f27aed@redhat.com>

Hi Thomas,

On 9/23/19 8:09 PM, Thomas Huth wrote:
> On 23/09/2019 16.31, Auger Eric wrote:
>> Hi Thomas,
>>
>> On 9/21/19 5:04 PM, Thomas Huth wrote:
>>> We are going to make CONFIG_ARM_V7M optional, so the related cortex-m
>>> CPUs should only be created if the switch is enabled. This can best
>>> be done if the code resides in a separate file, thus move the related
>>> functions to a new file v7m.c which only gets compiled if CONFIG_ARM_V7M
>>> is enabled.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>>  target/arm/Makefile.objs |   1 +
>>>  target/arm/cpu.c         | 146 -----------------------------
>>>  target/arm/v7m.c         | 193 +++++++++++++++++++++++++++++++++++++++
>>>  3 files changed, 194 insertions(+), 146 deletions(-)
>>>  create mode 100644 target/arm/v7m.c
> [...]
>>> diff --git a/target/arm/v7m.c b/target/arm/v7m.c
>>> new file mode 100644
>>> index 0000000000..505043febe
>>> --- /dev/null
>>> +++ b/target/arm/v7m.c
>>> @@ -0,0 +1,193 @@
>>> +/*
>>> + * ARM v7m helpers.
>>> + *
>>> + * This code is licensed under the GNU GPL v2 or later.
>>> + *
>>> + * SPDX-License-Identifier: GPL-2.0-or-later
>>> + */
>>> +
>>> +#include "qemu/osdep.h"
>>> +#include "qemu/qemu-print.h"
>>> +#include "qemu-common.h"
>>> +#include "target/arm/idau.h"
>>> +#include "qemu/module.h"
>>> +#include "qapi/error.h"
>>> +#include "qapi/visitor.h"
>>> +#include "cpu.h"
>>> +#include "internals.h"
>>> +#include "exec/exec-all.h"
>>> +#include "hw/qdev-properties.h"
>>> +#if !defined(CONFIG_USER_ONLY)
>>> +#include "hw/loader.h"
>>> +#include "hw/boards.h"
>>> +#endif
>>> +#include "sysemu/sysemu.h"
>>> +#include "sysemu/tcg.h"
>>> +#include "sysemu/hw_accel.h"
>>> +#include "disas/capstone.h"
>>> +#include "fpu/softfloat.h"
>>
>> I guess some of those headers are not needed.
> 
> Yeah, I just copy-n-pasted from the source file ... I'll check what can
> be omitted (if this patch series has a chance at all...)
> 
>>> +
>>> +#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
>>> +
>>> +static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
>>> +{
>>> +    CPUClass *cc = CPU_GET_CLASS(cs);
>>> +    ARMCPU *cpu = ARM_CPU(cs);
>>> +    CPUARMState *env = &cpu->env;
>>> +    bool ret = false;
>>> +
>>> +    /*
>>> +     * ARMv7-M interrupt masking works differently than -A or -R.
>>> +     * There is no FIQ/IRQ distinction. Instead of I and F bits
>>> +     * masking FIQ and IRQ interrupts, an exception is taken only
>>> +     * if it is higher priority than the current execution priority
>>> +     * (which depends on state like BASEPRI, FAULTMASK and the
>>> +     * currently active exception).
>>> +     */
>>> +    if (interrupt_request & CPU_INTERRUPT_HARD
>>> +        && (armv7m_nvic_can_take_pending_exception(env->nvic))) {
>>
>> so what is the status wrt m_helper.c which stays unconditionally
>> compiled. m_helper functions seem to called from target/arm/translate.c
>> mostly. Have you abandoned the stub idea. It may be confusing to have 2
>> different helper files. At least a comment explaining where a new helper
>> shall go may be useful.
> 
> All the HELPER() functions should definitely stay in m_helper.c. They
> are required for linking. Or do you prefer a stub file instead? Then we
> could maybe make the whole m_helper.c conditional in the Makefile.objs
> instead.

I was simply referring to your previous approach:

Applying [Qemu-devel] [RFC PATCH 3/3] target/arm: Make m_helper.c
optional via CONFIG_ARM_V7M seems to fix the issue
https://lists.gnu.org/archive/html/qemu-devel/2019-09/msg00333.html

It seems to work fine as it removes the call to armv7m_nvic.c functions
so no need to move the interrupt controller code?

Thanks

Eric

> 
> However, there's one thing I currently don't quite understand in this
> code (since I'm not an ARM guy, sorry) : There are references to "v8" in
> m_helper.c, too. Is that related to a separate CPU type, ie. should the
> v8 code also be available when CONFIG_ARM_V7M is disabled? Or can the
> code in m_helper.c be disabled completely if CONFIG_ARM_V7M is not set?
> 
>  Thomas
> 


  parent reply	other threads:[~2019-09-24 11:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-21 15:04 [PATCH 0/4] Make it possible to compile with CONFIG_ARM_V7M=n Thomas Huth
2019-09-21 15:04 ` [PATCH 1/4] target/arm: Make cpu_register() and set_feature() available for other files Thomas Huth
2019-09-23 14:28   ` Auger Eric
2019-09-21 15:04 ` [PATCH 2/4] target/arm: Move cortex-m related functions to new file v7m.c Thomas Huth
2019-09-23 14:31   ` Auger Eric
2019-09-23 18:09     ` Thomas Huth
2019-09-23 18:45       ` Peter Maydell
2019-09-23 18:51         ` Thomas Huth
2019-09-23 18:54           ` Peter Maydell
2019-09-24 11:02       ` Auger Eric [this message]
2019-09-24 11:06         ` Thomas Huth
2019-09-24 11:24           ` Auger Eric
2019-09-23 14:34   ` Peter Maydell
2019-09-24  9:52     ` Philippe Mathieu-Daudé
2019-09-21 15:04 ` [PATCH 3/4] hw/arm: Move armv7m_nvic.c to hw/arm/ and always enable it for arm builds Thomas Huth
2019-09-23 14:52   ` Peter Maydell
2019-09-23 17:54     ` Thomas Huth
2019-09-23 18:27       ` Peter Maydell
2019-09-23 18:36         ` Thomas Huth
2019-09-23 18:50           ` Peter Maydell
2019-09-24  4:44             ` Thomas Huth
2019-09-24  9:42               ` Peter Maydell
2019-09-24  9:48                 ` Thomas Huth
2019-09-24 10:01                   ` Philippe Mathieu-Daudé
2019-09-21 15:04 ` [PATCH 4/4] default-configs: Do not enforce CONFIG_ARM_V7M anymore Thomas Huth
2019-09-23  8:37 ` [PATCH 0/4] Make it possible to compile with CONFIG_ARM_V7M=n Philippe Mathieu-Daudé
2019-09-23  8:50   ` Thomas Huth
2019-09-23  8:58     ` Philippe Mathieu-Daudé

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=5b967a2a-e1db-9a9f-7590-fc6905354f7a@redhat.com \
    --to=eric.auger@redhat.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 \
    --cc=thuth@redhat.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).