From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Zyngier Subject: Re: [kvm-unit-tests PATCH] arm64: add micro test Date: Thu, 3 May 2018 17:24:24 +0100 Message-ID: <6667183c-6a89-f6c8-e630-efa2faf5b003@arm.com> References: <1513372539-10180-1-git-send-email-shihwei@cs.columbia.edu> <1513372539-10180-2-git-send-email-shihwei@cs.columbia.edu> <20171218191037.wjocr7jbf5ua2duj@hawk.localdomain> <20171220170030.zvz3oounirnlhcfi@hawk.localdomain> <61a11d00-cc9c-bc17-eec0-0296085026e7@cavium.com> <0ee505ca-9022-0ec9-6008-9e49fb723d88@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: pbonzini@redhat.com, "kvmarm@lists.cs.columbia.edu" , kvm@vger.kernel.org, Christoffer Dall To: "Kalra, Ashish" , Andrew Jones , Shih-Wei Li Return-path: In-Reply-To: Content-Language: en-GB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org On 03/05/18 12:12, Kalra, Ashish wrote: > >>> >>> 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; >>> } > > There still is the issue of x1-x3 registers being used for local > variables and clobbering of the same across the "hvc" call. > > Comparatively, the fix below works more reliably : > > asm volatile("hvc #0" : "+r" (w0) :: "x1","x2","x3"); Is that because this hypercall is explicitly clobbering these registers? or because KVM is corrupting them? If the former, fine. If the latter, that'd be a KVM bug. So which one is it? M. -- Jazz is not dead. It just smells funny...