qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	Peter Maydell <peter.maydell@linaro.org>,
	Christopher Covington <cov@codeaurora.org>,
	Alistair Francis <alistair.francis@xilinx.com>
Subject: Re: [Qemu-devel] [PATCH v1 7/7] target-arm: Call the pmccntr_sync function when swapping ELs
Date: Thu, 26 Jun 2014 10:37:05 +1000	[thread overview]
Message-ID: <CAKmqyKPnqp0_CUfq_SOxR2a4MDRKNih25XNZfvLn7swkHbc4xA@mail.gmail.com> (raw)
In-Reply-To: <CAEgOgz5GGPAieLC2L2-SX1ZRgyPy0+JGV50rDm+jcjByj-mo0w@mail.gmail.com>

On Wed, Jun 25, 2014 at 9:07 AM, Peter Crosthwaite
<peter.crosthwaite@xilinx.com> wrote:
> On Wed, Jun 25, 2014 at 8:39 AM, Alistair Francis
> <alistair.francis@xilinx.com> wrote:
>> On Wed, Jun 25, 2014 at 1:55 AM, Christopher Covington
>> <cov@codeaurora.org> wrote:
>>> On 06/23/2014 09:12 PM, Alistair Francis wrote:
>>>> Call the new pmccntr_sync() function when there is a possibility
>>>> of swapping ELs (I.E. when there is an exception)
>>>>
>>>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>>>> ---
>>>>
>>>>  target-arm/helper-a64.c |    5 +++++
>>>>  target-arm/helper.c     |    7 +++++++
>>>>  target-arm/op_helper.c  |    6 ++++++
>>>>  3 files changed, 18 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
>>>> index 2b4ce6a..b61174f 100644
>>>> --- a/target-arm/helper-a64.c
>>>> +++ b/target-arm/helper-a64.c
>>>> @@ -446,6 +446,8 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
>>>>      target_ulong addr = env->cp15.vbar_el[1];
>>>>      int i;
>>>>
>>>> +    pmccntr_sync(env);
>>>> +
>>>>      if (arm_current_pl(env) == 0) {
>>>>          if (env->aarch64) {
>>>>              addr += 0x400;
>>>> @@ -484,6 +486,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
>>>>          addr += 0x100;
>>>>          break;
>>>>      default:
>>>> +        pmccntr_sync(env);
>>>>          cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
>
> Not sure you need this, there is not much point in causing your side
> effects right before an assertion (via cpu_abort).

I figured it doesn't really matter. Plus it could make debugging
easier if someone
was monitoring the registers?

>
>>>>      }
>>>>
>>>> @@ -511,4 +514,6 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
>>>>
>>>>      env->pc = addr;
>>>>      cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
>>>> +
>>>> +    pmccntr_sync(env);
>>>>  }
>>>
>>> The double calls seem unwieldy. I think it could be made into a single
>>> function call if there was access, perhaps as a second parameter or maybe as a
>>> static variable, to both the previous and current state so the function could
>>> tell whether there is no transition, enable->disable, or disable->enable.
>>>
>>
>> The problem with a parameter is that the state of the enabled register needs
>> to be saved at the start of any code that will enable/disable the register. So
>> it ends up being just as messy.
>>
>> Static variables won't work if there are multiple CPUs. I guess an
>> array of statics
>> could work, but I don't like that method
>>
>> I feel that just calling the function twice ends up being neat and
>> works pretty well
>>
>
> Theres a third option. Create a new function that explicitly changes EL:
>
> arm_change_el(int new) {
>     sync();
>     env->el = new;
>     sync();
> }
>
> And update the interrupt path functions to use it instead of direct
> env manipulation.
>
> The advantage of this, is others can also add el switching side
> effects in one place. I doubt this is the last time we will want to
> trap EL changes for system level side effects.

That doesn't really fix the problem, because the sync function will still
need to exist as there are other places where the counter can be
enabled/disabled. So it just moves it to a different place. I also feel
that that's pretty much what the
*cpu_do_interrupt() functions already do

Could that also interfere with the work that is being done to support EL2
and 3?

>
> Regards,
> Peter
>
>>> Christopher
>>>
>>> --
>>> Employee of Qualcomm Innovation Center, Inc.
>>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
>>> hosted by the Linux Foundation.
>>>
>>
>

  reply	other threads:[~2014-06-26  0:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24  1:11 [Qemu-devel] [PATCH v1 0/7] target-arm: Extend PMCCNTR for ARMv8 Alistair Francis
2014-06-24  1:11 ` [Qemu-devel] [PATCH v1 1/7] target-arm: Make the ARM PMCCNTR register 64-bit Alistair Francis
2014-06-24  1:11 ` [Qemu-devel] [PATCH v1 2/7] target-arm: Implement PMCCNTR_EL0 and related registers Alistair Francis
2014-06-24  1:12 ` [Qemu-devel] [PATCH v1 3/7] target-arm: Add helper macros and defines for CCNT register Alistair Francis
2014-06-24 15:31   ` Christopher Covington
2014-06-24 22:40     ` Alistair Francis
2014-06-24 15:56   ` Peter Maydell
2014-06-24 22:42     ` Alistair Francis
2014-06-24  1:12 ` [Qemu-devel] [PATCH v1 4/7] target-arm: Implement pmccntr_sync function Alistair Francis
2014-06-24 15:35   ` Christopher Covington
2014-06-24 22:34     ` Alistair Francis
2014-06-24  1:12 ` [Qemu-devel] [PATCH v1 5/7] target-arm: Remove old code and replace with new functions Alistair Francis
2014-06-24  1:12 ` [Qemu-devel] [PATCH v1 6/7] target-arm: Implement pmccfiltr_write function Alistair Francis
2014-06-24  1:12 ` [Qemu-devel] [PATCH v1 7/7] target-arm: Call the pmccntr_sync function when swapping ELs Alistair Francis
2014-06-24 15:55   ` Christopher Covington
2014-06-24 22:39     ` Alistair Francis
2014-06-24 23:07       ` Peter Crosthwaite
2014-06-26  0:37         ` Alistair Francis [this message]
2014-06-26 11:40   ` Peter Crosthwaite
2014-06-26 11:43     ` Peter Crosthwaite
2014-06-26 14:58 ` [Qemu-devel] [PATCH v1 0/7] target-arm: Extend PMCCNTR for ARMv8 Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2014-06-26  5:06 [Qemu-devel] [PATCH v1 7/7] target-arm: Call the pmccntr_sync function when swapping ELs Alistair Francis

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=CAKmqyKPnqp0_CUfq_SOxR2a4MDRKNih25XNZfvLn7swkHbc4xA@mail.gmail.com \
    --to=alistair.francis@xilinx.com \
    --cc=cov@codeaurora.org \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).