On 01/05/18 15:57, Kalra, Ashish wrote: > Hello Shih-Wei, > > This exception is probably due to a bug in the hvc_test (hvc call) code, > and there is a generic bug in the hvc test code. > In the function hvc_test(), local variables c1, c2 get mapped to > registers (typically x1 & x2) and those are "clobbered" across the hvc > call, hence, c1 gets clobbered and we get a large cycle count for > hvc_test (c2 - 0), which messes-up the hvc test measurements. > > As per SMC64/HVC64 ABI definitions, x0-x18 can be clobbered across > HVC/SMC calls. I have two issues with this statement: - Version 1.1 of the SMCCC actually says that only x0-x3 will be potentially clobbered - KVM makes a point in not clobbering any register, except for those functions implemented by SMCCC 1.1. That being said... > > Currently, i am using your micro-benchmark code with the following > hack applied ... > > +register unsigned long c1_hvc asm ("x19"); > > > static unsigned long hvc_test(void) > > > { > + unsigned long c2; > - unsigned long c1, c2; > > > > > > > + c1_hvc = read_cc(); > - c1 = read_cc(); > asm volatile("mov w0, #0x4b000000; hvc #0" ::: "w0"); > > > c2 = read_cc(); The reason for the problem you're seeing is probably that the constraints are not quite right. Here, x0 is not simply clobbered, but is actively written to in the middle of the sequence (it is at least an early clobber). It is also, I assume, a result from the hypercall, so it cannot simply be discarded. It would help to get a disassembly of the function, but I'd tend to rewrite the code as such: extern int bar(void); int foo(void) { register int w0 asm("w0"); int a, b; a = bar(); w0 = 0x4b000000; asm volatile("hvc #0" : "+r" (w0) :: ); b = bar(); return a - b; } Thanks, M. -- Jazz is not dead. It just smells funny...