From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ry76c-0001Qq-IK for qemu-devel@nongnu.org; Thu, 16 Feb 2012 14:35:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ry76W-0002Jo-9a for qemu-devel@nongnu.org; Thu, 16 Feb 2012 14:35:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46384) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ry76V-0002Ji-VT for qemu-devel@nongnu.org; Thu, 16 Feb 2012 14:34:56 -0500 Message-ID: <4F3D5A59.20803@redhat.com> Date: Thu, 16 Feb 2012 21:34:49 +0200 From: Avi Kivity MIME-Version: 1.0 References: <4F2AB552.2070909@redhat.com> <20120205093723.GQ23536@redhat.com> <4F2E4F8B.8090504@redhat.com> <20120205095153.GA29265@redhat.com> <4F2EAFF6.7030006@codemonkey.ws> <4F2F9E89.7090607@redhat.com> <87vcnih5qt.fsf@rustcorp.com.au> <4F3BB59D.2020505@redhat.com> <4F3C2AC5.80400@codemonkey.ws> <20120216085741.GB19771@redhat.com> <4F3D16BB.5060804@codemonkey.ws> In-Reply-To: <4F3D16BB.5060804@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] Next gen kvm api List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel , Rusty Russell , KVM list , Gleb Natapov , linux-kernel On 02/16/2012 04:46 PM, Anthony Liguori wrote: >> What will it buy us? Surely not speed. Entering a guest is not much >> (if at all) faster than exiting to userspace and any non trivial >> operation will require exit to userspace anyway, > > > You can emulate the PIT/RTC entirely within the guest using kvmclock > which doesn't require an additional exit to get the current time base. > > So instead of: > > 1) guest -> host kernel > 2) host kernel -> userspace > 3) implement logic using rdtscp via VDSO > 4) userspace -> host kernel > 5) host kernel -> guest > > You go: > > 1) guest -> host kernel > 2) host kernel -> guest (with special CR3) > 3) implement logic using rdtscp + kvmclock page > 4) change CR3 within guest and RETI to VMEXIT source RIP > > Same basic concept as PS/2 emulation with SMM. Interesting, but unimplementable in practice. SMM requires a VMEXIT for RSM, and anything non-SMM wants a virtual address mapping (and some RAM) which you can't get without guest cooperation. There are other complications like an NMI interrupting hypervisor-provided code and finding unexpected addresses on its stack (SMM at least blocks NMIs). Tangentially related, Intel introduced a VMFUNC that allows you to change the guest's physical memory map to a pre-set alternative provided by the host, without a VMEXIT. Seems similar to SMM but requires guest cooperation. I guess it's for unintrusive virus scanners and the like. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.