git: c2de5317816e - stable/13 - MFC: arm64 fixes for TSLOG

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Wed, 29 Dec 2021 23:06:24 UTC
The branch stable/13 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=c2de5317816e10e1730ca0283f80ca710eade3ea

commit c2de5317816e10e1730ca0283f80ca710eade3ea
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2021-06-24 05:10:26 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2021-12-29 22:53:18 +0000

    MFC: arm64 fixes for TSLOG
    
    arm64: Disable early printf if TSLOG
    arm64: Instrument initarm with TSLOG
    libsa: Add tslog support for arm64
    
    Sponsored by:   https://www.patreon.com/cperciva
    
    (cherry picked from commit 0acc529dc35f88836dbcbe75940954c75595b058)
    (cherry picked from commit ccadcb8f3343562f22a426e845dba640319d4355)
    (cherry picked from commit e6caac717b4fc2b87cf93f67109884e768253e77)
---
 stand/libsa/tslog.c       | 6 ++++++
 sys/arm64/arm64/machdep.c | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/stand/libsa/tslog.c b/stand/libsa/tslog.c
index 7ea18e0bb8f8..c6164aab02a9 100644
--- a/stand/libsa/tslog.c
+++ b/stand/libsa/tslog.c
@@ -29,7 +29,11 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 
+#if defined(__amd64__) || defined(__i386__)
 #include <machine/cpufunc.h>
+#elif defined(__aarch64__)
+#include <machine/armreg.h>
+#endif
 
 #include <stand.h>
 
@@ -60,6 +64,8 @@ tslog(const char * type, const char * f, const char * s)
 {
 #if defined(__amd64__) || defined(__i386__)
 	uint64_t tsc = rdtsc();
+#elif defined(__aarch64__)
+	uint64_t tsc = READ_SPECIALREG(cntvct_el0);
 #else
 	uint64_t tsc = 0;
 #endif
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 3ea7e850d70e..67f6f66241f8 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -557,7 +557,9 @@ try_load_dtb(caddr_t kmdp)
 #endif
 
 	if (dtbp == (vm_offset_t)NULL) {
+#ifndef TSLOG
 		printf("ERROR loading DTB\n");
+#endif
 		return;
 	}
 
@@ -707,6 +709,8 @@ initarm(struct arm64_bootparams *abp)
 	caddr_t kmdp;
 	bool valid;
 
+	TSRAW(&thread0, TS_ENTER, __func__, NULL);
+
 	boot_el = abp->boot_el;
 
 	/* Parse loader or FDT boot parametes. Determine last used address. */
@@ -838,6 +842,8 @@ initarm(struct arm64_bootparams *abp)
 	}
 
 	early_boot = 0;
+
+	TSEXIT();
 }
 
 void