From: Pranith Kumar <bobby.prani@gmail.com>
To: alex.bennee@linaro.org
Cc: qemu-devel@nongnu.org, rth@twiddle.net
Subject: [Qemu-devel] [PATCH 1/2] [TEST] aarch64: Use pmuserenr_el0 register for instrumentation
Date: Wed, 28 Jun 2017 01:00:02 -0400 [thread overview]
Message-ID: <20170628050003.1809-2-bobby.prani@gmail.com> (raw)
In-Reply-To: <20170628050003.1809-1-bobby.prani@gmail.com>
We need a way for the benchmark running in the guest to indicate us to
start/stop our instrumentation. On x86, we could use the 'cpuid'
instruction along with an appropriately populated 'eax'
register. However, no such dummy instruction exists for aarch64. So
we modify the permission bits for 'pmuserenr_el0' register and tap
that to instrument the guest code.
You can use the following annotations on your region-of-interest to
instrument the code.
#define magic_enable() \
asm volatile ("msr pmuserenr_el0, %0" :: "r" (0xaaaaaaaa));
#define magic_disable() \
asm volatile ("msr pmuserenr_el0, %0" :: "r" (0xfa11dead));
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
target/arm/helper.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 2594faa9b8..dfbf03676c 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1124,9 +1124,24 @@ static uint64_t pmxevtyper_read(CPUARMState *env, const ARMCPRegInfo *ri)
}
}
+bool enable_instrumentation;
+
static void pmuserenr_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
+ ARMCPU *cpu = arm_env_get_cpu(env);
+ CPUState *cs = CPU(cpu);
+
+ if (value == 0xaaaaaaaa) {
+ printf("Enabling instrumentation\n");
+ enable_instrumentation = true;
+ tb_flush(cs);
+ } else if (value == 0xfa11dead) {
+ printf("Disabling instrumentation\n");
+ enable_instrumentation = false;
+ tb_flush(cs);
+ }
+
if (arm_feature(env, ARM_FEATURE_V8)) {
env->cp15.c9_pmuserenr = value & 0xf;
} else {
@@ -1316,13 +1331,13 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
.access = PL0_RW, .type = ARM_CP_CONST, .resetvalue = 0,
.accessfn = pmreg_access_xevcntr },
{ .name = "PMUSERENR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 0,
- .access = PL0_R | PL1_RW, .accessfn = access_tpm,
+ .access = PL0_RW | PL1_RW, .accessfn = access_tpm,
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmuserenr),
.resetvalue = 0,
.writefn = pmuserenr_write, .raw_writefn = raw_write },
{ .name = "PMUSERENR_EL0", .state = ARM_CP_STATE_AA64,
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 14, .opc2 = 0,
- .access = PL0_R | PL1_RW, .accessfn = access_tpm, .type = ARM_CP_ALIAS,
+ .access = PL0_RW | PL1_RW, .accessfn = access_tpm, .type = ARM_CP_ALIAS,
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmuserenr),
.resetvalue = 0,
.writefn = pmuserenr_write, .raw_writefn = raw_write },
--
2.13.0
next prev parent reply other threads:[~2017-06-28 5:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-28 5:00 [Qemu-devel] [TEST PATCH 0/2] Instrumentation and TLB stats Pranith Kumar
2017-06-28 5:00 ` Pranith Kumar [this message]
2017-06-28 9:27 ` [Qemu-devel] [PATCH 1/2] [TEST] aarch64: Use pmuserenr_el0 register for instrumentation Peter Maydell
2017-06-28 5:00 ` [Qemu-devel] [PATCH 2/2] [TEST] Collect TLB and victim TLB hit/miss stats Pranith Kumar
2017-07-10 10:03 ` Alex Bennée
2017-07-10 12:24 ` Paolo Bonzini
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=20170628050003.1809-2-bobby.prani@gmail.com \
--to=bobby.prani@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).