shithub: riscv

Download patch

ref: 4ba5cb6c6abc5ffa988c0b3d78e3151efddac4f5
parent: 01eb04060b0de65eca044566381e214fab99fea3
author: cinap_lenrek <[email protected]>
date: Tue Dec 8 08:04:52 EST 2020

vmx: nanosec(): fix non-interruptable temporary, assign fasthz only once after xstart

--- a/sys/src/cmd/vmx/nanosec.c
+++ b/sys/src/cmd/vmx/nanosec.c
@@ -17,14 +17,15 @@
 		return nsec() - xstart;
 
 	if(fasthz == 0){
-		if((fasthz = _tos->cyclefreq) == 0){
-			fasthz = ~0ULL;
+		if(_tos->cyclefreq){
+			cycles(&xstart);
+			fasthz = _tos->cyclefreq;
+		} else {
 			xstart = nsec();
+			fasthz = ~0ULL;
 			fprint(2, "cyclefreq not available, falling back to nsec()\n");
 			fprint(2, "you might want to disable aux/timesync\n");
 			return 0;
-		}else{
-			cycles(&xstart);
 		}
 	}
 	cycles(&x);