All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Christoffer Dall <c.dall@virtualopensystems.com>,
	Rusty Russell <rusty.russell@linaro.org>
Cc: android-virt@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@linaro.org
Subject: Re: [PATCH 2/3] ARM: KVM: Fake up performance counters a little more precisely.
Date: Thu, 17 May 2012 09:42:21 +0930	[thread overview]
Message-ID: <87ipfv3btm.fsf@rustcorp.com.au> (raw)
In-Reply-To: <CANM98q+N7i4VTKk9d3t=wgarz6xs7wVmoVOEDOSj6P+0YUKteg@mail.gmail.com>

On Mon, 14 May 2012 18:49:40 -0400, Christoffer Dall <c.dall@virtualopensystems.com> wrote:
> On Thu, Mar 29, 2012 at 1:17 AM, Rusty Russell <rusty.russell@linaro.org> wrote:
> > Rather than just making all of c9 read-zero/write-discard, this changes
> > it to the explicit profiling registers we need.  This is a start for the
> > future implementation were we actually implement performance monitoring,
> > and makes sure we're not discarding important things.
> >
> > Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
> > ---
> >  arch/arm/kvm/emulate.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 files changed, 65 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c
> > index aec1b6e..4bdab8f 100644
> > --- a/arch/arm/kvm/emulate.c
> > +++ b/arch/arm/kvm/emulate.c
> > @@ -238,6 +238,64 @@ static bool read_l2ctlr(struct kvm_vcpu *vcpu,
> >        return true;
> >  }
> >
> > +static bool read_pmcr(struct kvm_vcpu *vcpu,
> > +                     const struct coproc_params *p,
> > +                     unsigned long arg)
> > +{
> > +       u32 imp, idcode, num;
> > +
> > +       imp = (vcpu->arch.cp15[c0_MIDR] & 0xFF000000) >> 24;
> > +       idcode = (vcpu->arch.cp15[c0_MIDR] & 0x00000FF0) >> 4;
> 
> where does it say that idcode is always te same as MIDR?

Good point, it doesn't.  It is true for the Cortex A-15, at least.  This
would be more generically a switch statement on "what CPU are we" ioctl,
as I mentioned in the previous mail.

> > +       /* No counters. */
> > +       num = 0;
> > +
> > +       /* Other bits are at reset value. */
> 
> what's the point of writing anything below then? I would assume that
> you can have really weird behavior if you read something different
> from what you once wrote, shouldn't you read num from the vcpu value
> with the bit-filter below?

I think I meant that the other bits are 0 at reset.  But yes, some
should be read back as written.

This would mean saving what they actually wrote, which is not a bad
idea.

> > +/* FIXME: We ignore them enabling performance monitoring. */
> 
> if this is a FIXME, then how is it eventually going to be fixed?

I was thinking that eventually we implement performance monitoring?

> > +static bool write_pmcr(struct kvm_vcpu *vcpu,
> > +                      const struct coproc_params *p,
> > +                      unsigned long arg)
> > +{
> > +       u32 val = *vcpu_reg(vcpu, p->Rt1);
> > +
> > +       kvm_debug("pmcr write:%s%s%s%s%s%s\n",
> > +                 val & (1 << 5) ? " DP" : "",
> > +                 val & (1 << 4) ? " X" : "",
> > +                 val & (1 << 3) ? " D" : "",
> > +                 val & (1 << 2) ? " C" : "",
> > +                 val & (1 << 1) ? " P" : "",
> > +                 val & (1 << 0) ? " E" : "");
> > +       return true;
> > +}
> > +
> > +static bool read_pmcntenclr(struct kvm_vcpu *vcpu,
> > +                           const struct coproc_params *p,
> > +                           unsigned long arg)
> > +{
> > +       /* Cycle counter is off, there are no others. */
> > +       *vcpu_reg(vcpu, p->Rt1) = 0;
> > +       return true;
> > +}
> > +
> > +static bool write_pmcntenclr(struct kvm_vcpu *vcpu,
> > +                           const struct coproc_params *p,
> > +                           unsigned long arg)
> > +{
> > +       /* Writing a 1 means disable a counter.  That's cool. */
> > +       return true;
> > +}
> > +
> > +static bool write_pmintenclr(struct kvm_vcpu *vcpu,
> > +                            const struct coproc_params *p,
> > +                            unsigned long arg)
> > +{
> > +       /* Writing a 1 means disable an overflow interrupt.  That's cool. */
> > +       return true;
> > +}
> > +
> >  static bool access_cp15_reg(struct kvm_vcpu *vcpu,
> >                            const struct coproc_params *p,
> >                            unsigned long cp15_reg)
> > @@ -279,13 +337,18 @@ struct coproc_emulate {
> >  static const struct coproc_emulate coproc_emulate[] = {
> >        /*
> >         * L2CTLR access (guest wants to know #CPUs).
> > -        *
> > -        * FIXME: Hack Alert: Read zero as default case.
> >         */
> >        { CRn( 9), CRm( 0), Op1( 1), Op2( 2), is32,  READ,  read_l2ctlr},
> >        { CRn( 9), CRm(DF), Op1(DF), Op2(DF), is32,  WRITE, ignore_write},
> >        { CRn( 9), CRm(DF), Op1(DF), Op2(DF), is32,  READ,  read_zero},
> >
> > +       /* Guest reads/writes PMU, assuming there will be one. */
> > +       { CRn( 9), CRm(12), Op1( 0), Op2( 0), is32,  READ,  read_pmcr},
> > +       { CRn( 9), CRm(12), Op1( 0), Op2( 0), is32,  WRITE, write_pmcr},
> > +       { CRn( 9), CRm(12), Op1( 0), Op2( 2), is32,  READ,  read_pmcntenclr},
> > +       { CRn( 9), CRm(12), Op1( 0), Op2( 2), is32,  WRITE, write_pmcntenclr},
> > +       { CRn( 9), CRm(14), Op1( 0), Op2( 2), is32,  WRITE, write_pmintenclr},
> > +
> 
> won't all the DF versions above "eat" these calls? Should they just go
> away or are there still default cases to catch in which case the
> comment about reading zero should perhaps be modified to specifically
> mention these cases?

Posted in too much of a hurry.  Yes, the DFs to get removed.

I'll re-spin this, and re-test.

Thanks,
Rusty.


  reply	other threads:[~2012-05-17  3:37 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12  6:51 [PATCH v7 00/12] KVM/ARM Implementation Christoffer Dall
2012-03-12  6:51 ` [PATCH v7 01/12] KVM: Introduce __KVM_HAVE_IRQ_LINE Christoffer Dall
2012-03-23  0:41   ` [PATCH] ARM: KVM: Check the cpuid we're being asked to emulate Rusty Russell
2012-05-14 22:57     ` Christoffer Dall
2012-05-16 23:58       ` Rusty Russell
2012-05-20 18:34         ` Christoffer Dall
2012-05-21  1:13           ` Rusty Russell
2012-03-12  6:52 ` [PATCH v7 02/12] KVM: Guard mmu_notifier specific code with CONFIG_MMU_NOTIFIER Christoffer Dall
2012-03-12 15:50   ` Avi Kivity
2012-03-12  6:52 ` [PATCH v7 03/12] ARM: KVM: Initial skeleton to compile KVM support Christoffer Dall
2012-03-12  6:52 ` [PATCH v7 04/12] ARM: KVM: Hypervisor identity mapping Christoffer Dall
2012-03-12  6:52 ` [PATCH v7 05/12] ARM: KVM: Hypervisor inititalization Christoffer Dall
2012-03-12  6:52 ` [PATCH v7 06/12] ARM: KVM: Memory virtualization setup Christoffer Dall
2012-03-12  6:52 ` [PATCH v7 07/12] ARM: KVM: Inject IRQs and FIQs from userspace Christoffer Dall
2012-03-12  6:52 ` [PATCH v7 08/12] ARM: KVM: World-switch implementation Christoffer Dall
2012-03-23  0:23   ` Rusty Russell
2012-03-28 13:05     ` Avi Kivity
2012-03-28 21:57       ` Rusty Russell
2012-03-29 10:49         ` Avi Kivity
2012-05-14 18:08           ` Christoffer Dall
2012-03-12  6:52 ` [PATCH v7 09/12] ARM: KVM: Emulation framework and CP15 emulation Christoffer Dall
2012-03-12  6:52 ` [PATCH v7 10/12] ARM: KVM: Handle guest faults in KVM Christoffer Dall
2012-03-12 15:31   ` [Android-virt] " Marc Zyngier
2012-03-12 16:23     ` Christoffer Dall
2012-03-12 16:28       ` Marc Zyngier
2012-03-12  6:53 ` [PATCH v7 11/12] ARM: KVM: Handle I/O aborts Christoffer Dall
2012-03-12  6:53 ` [PATCH v7 12/12] ARM: KVM: Guest wait-for-interrupts (WFI) support Christoffer Dall
2012-03-12 17:36 ` [PATCH v7 00/12] KVM/ARM Implementation Avi Kivity
2012-03-23  0:40 ` [PATCH] ARM: KVM: Remove l2ctlr write Rusty Russell
2012-05-14 22:59   ` Christoffer Dall
2012-03-29  5:11 ` [PATCH 0/3] Emulation cleanups Rusty, Russell <rusty.russell
2012-03-29  5:15   ` [PATCH 1/3] ARM: KVM: Remove l2ctlr write Rusty Russell
2012-03-29  5:17   ` [PATCH 2/3] ARM: KVM: Fake up performance counters a little more precisely Rusty Russell
2012-05-14 22:49     ` Christoffer Dall
2012-05-17  0:12       ` Rusty Russell [this message]
2012-03-29  5:17   ` [PATCH 3/3] ARM: KVM: Check the cpuid we're being asked to emulate Rusty Russell

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=87ipfv3btm.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=android-virt@lists.cs.columbia.edu \
    --cc=c.dall@virtualopensystems.com \
    --cc=kvm@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rusty.russell@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 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.