From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Huang Subject: [kvm-unit-tests RFC 1/3] x86/pmu: Move common x86 PMU definitions to pmu.h Date: Thu, 3 Aug 2017 23:24:28 -0500 Message-ID: <1501820670-23194-2-git-send-email-wei@redhat.com> References: <1501820670-23194-1-git-send-email-wei@redhat.com> Cc: pbonzini@redhat.com, rkrcmar@redhat.com, wei@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60924 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751257AbdHDEYd (ORCPT ); Fri, 4 Aug 2017 00:24:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC8EB883AE for ; Fri, 4 Aug 2017 04:24:32 +0000 (UTC) In-Reply-To: <1501820670-23194-1-git-send-email-wei@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This patch moves common x86 PMU counter and event defintions to pmu.h file. This header file will be used by both Intel and AMD PMU test code. Signed-off-by: Wei Huang --- x86/pmu.c | 38 ++------------------------------------ x86/pmu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 x86/pmu.h diff --git a/x86/pmu.c b/x86/pmu.c index a0238dc..1b818c2 100644 --- a/x86/pmu.c +++ b/x86/pmu.c @@ -8,38 +8,9 @@ #include "x86/vm.h" #include "libcflat.h" +#include "pmu.h" #include -#define FIXED_CNT_INDEX 32 -#define PC_VECTOR 32 - -#define EVNSEL_EVENT_SHIFT 0 -#define EVNTSEL_UMASK_SHIFT 8 -#define EVNTSEL_USR_SHIFT 16 -#define EVNTSEL_OS_SHIFT 17 -#define EVNTSEL_EDGE_SHIFT 18 -#define EVNTSEL_PC_SHIFT 19 -#define EVNTSEL_INT_SHIFT 20 -#define EVNTSEL_EN_SHIF 22 -#define EVNTSEL_INV_SHIF 23 -#define EVNTSEL_CMASK_SHIFT 24 - -#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) -#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) -#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) -#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) -#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) -#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) - -#define N 1000000 - -typedef struct { - uint32_t ctr; - uint32_t config; - uint64_t count; - int idx; -} pmu_counter_t; - union cpuid10_eax { struct { unsigned int version_id:8; @@ -72,12 +43,7 @@ union cpuid10_edx { unsigned int full; } edx; -struct pmu_event { - const char *name; - uint32_t unit_sel; - int min; - int max; -} gp_events[] = { +struct pmu_event gp_events[] = { {"core cycles", 0x003c, 1*N, 50*N}, {"instructions", 0x00c0, 10*N, 10.2*N}, {"ref cycles", 0x013c, 0.1*N, 30*N}, diff --git a/x86/pmu.h b/x86/pmu.h new file mode 100644 index 0000000..b1e8e51 --- /dev/null +++ b/x86/pmu.h @@ -0,0 +1,42 @@ +/* vPMU unit testing for x86 */ +#ifndef __PMU_H +#define __PMU_H + +#define N 1000000 + +#define FIXED_CNT_INDEX 32 +#define PC_VECTOR 32 + +#define EVNTSEL_EVENT_SHIFT 0 +#define EVNTSEL_UMASK_SHIFT 8 +#define EVNTSEL_USR_SHIFT 16 +#define EVNTSEL_OS_SHIFT 17 +#define EVNTSEL_EDGE_SHIFT 18 +#define EVNTSEL_PC_SHIFT 19 +#define EVNTSEL_INT_SHIFT 20 +#define EVNTSEL_EN_SHIF 22 +#define EVNTSEL_INV_SHIF 23 +#define EVNTSEL_CMASK_SHIFT 24 + +#define EVNTSEL_EN (1 << EVNTSEL_EN_SHIF) +#define EVNTSEL_USR (1 << EVNTSEL_USR_SHIFT) +#define EVNTSEL_OS (1 << EVNTSEL_OS_SHIFT) +#define EVNTSEL_PC (1 << EVNTSEL_PC_SHIFT) +#define EVNTSEL_INT (1 << EVNTSEL_INT_SHIFT) +#define EVNTSEL_INV (1 << EVNTSEL_INV_SHIF) + +typedef struct { + uint32_t ctr; + uint32_t config; + uint64_t count; + int idx; +} pmu_counter_t; + +struct pmu_event { + const char *name; + uint32_t unit_sel; + int min; + int max; +}; + +#endif /* __PMU_H */ -- 2.7.5