Help configuring PMU's

Hi,

I'm trying to enable PMU's on arm versatile juno r2 development board.

I've already read this manuals from arm:
ARM ® Cortex ® -A72 MPCore Processor
ARM® Cortex ® -A53 MPCore Processor
Juno r2 ARM® Development Platform SoC
ARM® Architecture Reference Manual ARMv8, for ARMv8-A architecture profile

Searching online I found this guides:
http://zhiyisun.github.io/2016/03/02/How-to-Use-Performance-Monitor-Unit-(PMU)-of-64-bit-ARMv8-A-in-Linux.html
http://valtrix.in/programming/programming-armv8-performance-counters
http://syndication2605.rssing.com/chan-30054360/latest.php#item4
https://github.com/thoughtpolice/enable_arm_pmu/blob/master/ko/enable_arm_pmu.c
http://ilinuxkernel.com/?p=1755

The code i'm trying to compile (from the github link) on my host machine is:

/*
 * Enable user-mode ARM performance counter access.
 */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/smp.h>

/** -- Configuration stuff ------------------------------------------------- */

#define DRVR_NAME "enable_arm_pmu"

#if !defined(__arm__)
#error Module can only be compiled on ARM machines.
#endif

/** -- Initialization & boilerplate ---------------------------------------- */

#define PERF_DEF_OPTS (1 | 16)
#define PERF_OPT_RESET_CYCLES (2 | 4)
#define PERF_OPT_DIV64 (8)

static void
enable_cpu_counters(void* data)
{
        printk(KERN_INFO "[" DRVR_NAME "] enabling user-mode PMU access on CPU #%d",
                smp_processor_id());

        /* Enable user-mode access to counters. */
        asm volatile("mcr p15, 0, %0, c9, c14, 0" :: "r"(1));
        /* Program PMU and enable all counters */
        asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(PERF_DEF_OPTS));
        asm volatile("mcr p15, 0, %0, c9, c12, 1" :: "r"(0x8000000f));
}

static void
disable_cpu_counters(void* data)
{
        printk(KERN_INFO "[" DRVR_NAME "] disabling user-mode PMU access on CPU #%d",
                smp_processor_id());

        /* Program PMU and disable all counters */
        asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(0));
        asm volatile("mcr p15, 0, %0, c9, c12, 2" :: "r"(0x8000000f));
        /* Disable user-mode access to counters. */
        asm volatile("mcr p15, 0, %0, c9, c14, 0" :: "r"(0));
}

static int __init
init(void)
{
        on_each_cpu(enable_cpu_counters, NULL, 1);
        printk(KERN_INFO "[" DRVR_NAME "] initialized");
        return 0;
}

static void __exit
fini(void)
{
        on_each_cpu(disable_cpu_counters, NULL, 1);
        printk(KERN_INFO "[" DRVR_NAME "] unloaded");
}

MODULE_AUTHOR("Austin Seipp <aseipp@pobox.com>");
MODULE_LICENSE("Dual MIT/GPL");
MODULE_DESCRIPTION("Enables user-mode access to ARMv7 PMU counters");
MODULE_VERSION("0:0.1-dev");
module_init(init);
module_exit(fini);


I have a Makefile:
PWD := $(shell pwd)

obj-m += enable_arm_pmu.o

all:
	make ARCH=arm CROSS_COMPILE=$(CROSS) -C $(KERNEL) SUBDIRS=$(PWD) modules
clean:
	make -C $(KERNEL) SUBDIRS=$(PWD) clean


I'm compiling with:
make KERNEL=/lib/modules/4.13.0-45-generic/build CROSS=aarch64-linux-gnu-


I'm getting this output logs:
make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- -C /lib/modules/4.13.0-45-generic/build SUBDIRS=/home/lfpm1993/Desktop modules
make[1]: Entering directory '/usr/src/linux-headers-4.13.0-45-generic'
  CC [M]  /home/lfpm1993/Desktop/teste.o
aarch64-linux-gnu-gcc: error: unrecognized argument in option ‘-mabi=apcs-gnu’
aarch64-linux-gnu-gcc: note: valid arguments to ‘-mabi=’ are: ilp32 lp64
aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-mapcs’
aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-mno-sched-prolog’
aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-msoft-float’
scripts/Makefile.build:323: recipe for target '/home/lfpm1993/Desktop/teste.o' failed
make[2]: *** [/home/lfpm1993/Desktop/teste.o] Error 1
Makefile:1550: recipe for target '_module_/home/lfpm1993/Desktop' failed
make[1]: *** [_module_/home/lfpm1993/Desktop] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.13.0-45-generic'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2


Any ideas what I've done wrong?

Thanks,
Luís

More questions in this forum