From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [Android-virt] [PATCH v9 16/16] ARM: KVM: Guest wait-for-interrupts (WFI) support Date: Tue, 03 Jul 2012 18:57:13 +0300 Message-ID: <4FF31659.40908@redhat.com> References: <20120703085841.27746.82730.stgit@ubuntu> <20120703090212.27746.39517.stgit@ubuntu> <4FF2EF5F.8070207@redhat.com> <4FF2F288.4020502@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Christoffer Dall , tech@virtualopensystems.com, kvm@vger.kernel.org, android-virt@lists.cs.columbia.edu To: Peter Maydell Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52676 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755336Ab2GCP5Z (ORCPT ); Tue, 3 Jul 2012 11:57:25 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 07/03/2012 04:49 PM, Peter Maydell wrote: > On 3 July 2012 14:24, Avi Kivity wrote: >> On 07/03/2012 04:14 PM, Peter Maydell wrote: >>> You could just always wake the cpu when migrating: the >>> architecture allows WFI to return early for any reason >>> it likes including implementation convenience. >> >> Seems reasonable. >> >> I imagine wfi works with interrupts disabled, unlike the x86 silliness? > > Not sure exactly which bit of x86 silliness you're referring > to, but WFI will wake up regardless of the interrupt mask > bits in the CPSR. (If you've disabled interrupts in the GIC > that's your own bad lookout I guess.) On x86 HLT respects the interrupt enable flag, so to avoid races, you have to use a feature of STI (enable interrupts instruction) that only enables interrupts after another instruction has executed. So the sequence STI; HLT atomically enables interrupts and waits for one (as long as HLT didn't trigger an exception like a page fault). The problem is that this "interrupt shadow" has to be tracked by virtualization hardware, live migration, instruction emulation, etc. It interacts with non-maskable interrupts as well. A horrible hack. -- error compiling committee.c: too many arguments to function