From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [RFC] Next gen kvm api Date: Thu, 16 Feb 2012 21:34:49 +0200 Message-ID: <4F3D5A59.20803@redhat.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: qemu-devel , Rusty Russell , KVM list , Gleb Natapov , linux-kernel To: Anthony Liguori Return-path: In-Reply-To: <4F3D16BB.5060804@codemonkey.ws> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org 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.