From 1b86674fcbefb0c860c02ade0463db469f4df1bb Mon Sep 17 00:00:00 2001 From: Remy Noel Date: Wed, 18 Apr 2018 19:16:40 +0200 Subject: perfmon: Test overflow in cpu test. Adds perfmon_event_write as a test-only API. --- arch/x86/machine/pmu_intel.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'arch/x86/machine') diff --git a/arch/x86/machine/pmu_intel.c b/arch/x86/machine/pmu_intel.c index 6439282..40e1450 100644 --- a/arch/x86/machine/pmu_intel.c +++ b/arch/x86/machine/pmu_intel.c @@ -231,6 +231,21 @@ pmu_intel_read(unsigned int pmc_id) return cpu_get_msr64(PMU_INTEL_MSR_PMC0 + pmc_id); } +#ifdef CONFIG_PERFMON_TEST + +static void +pmu_intel_write(unsigned int pmc_id, uint64_t value) +{ + uint32_t low, high; + + low = value & 0xffffffff; + high = value >> 32; + + cpu_set_msr(PMU_INTEL_MSR_PMC0 + pmc_id, low, high); +} + +#endif /* CONFIG_PERFMON_TEST */ + static void pmu_intel_handle_of_intr_v1(struct trap_frame *frame) { @@ -318,6 +333,9 @@ pmu_intel_setup(void) pmu_driver.read = pmu_intel_read; pmu_driver.get_pmc_width = pmu_intel_get_pmc_width; pmu_driver.handle_of_intr = pmu_intel_handle_of_intr_v1; +#ifdef CONFIG_PERFMON_TEST + pmu_driver.write = pmu_intel_write; +#endif return perfmon_pmu_register(&pmu_driver); } -- cgit v1.2.3