xref: /linux/tools/perf/arch/arm64/util/tsc.c (revision da1d9caf95def6f0320819cf941c9fd1069ba9e1)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/types.h>
4 
5 #include "../../../util/tsc.h"
6 
7 u64 rdtsc(void)
8 {
9 	u64 val;
10 
11 	/*
12 	 * According to ARM DDI 0487F.c, from Armv8.0 to Armv8.5 inclusive, the
13 	 * system counter is at least 56 bits wide; from Armv8.6, the counter
14 	 * must be 64 bits wide.  So the system counter could be less than 64
15 	 * bits wide and it is attributed with the flag 'cap_user_time_short'
16 	 * is true.
17 	 */
18 	asm volatile("mrs %0, cntvct_el0" : "=r" (val));
19 
20 	return val;
21 }
22