From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Userspace MSR handling Date: Sun, 24 May 2009 15:07:20 +0300 Message-ID: <4A193878.4030206@redhat.com> References: <9ae48b020905221311h1859d5a1v3653404721d5208b@mail.gmail.com> <790CB8FA-1660-4F6B-BEEC-AAB9724DDD64@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Ed Swierk , "kvm@vger.kernel.org" To: Alexander Graf Return-path: Received: from mx2.redhat.com ([66.187.237.31]:56263 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752364AbZEXMH1 (ORCPT ); Sun, 24 May 2009 08:07:27 -0400 In-Reply-To: <790CB8FA-1660-4F6B-BEEC-AAB9724DDD64@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: Alexander Graf wrote: > > > > > On 22.05.2009, at 22:11, Ed Swierk wrote: > >> I'm experimenting with Gerd's excellent work on integrating Xenner >> into Qemu (http://git.et.redhat.com/?p=qemu-kraxel.git). I'm using it >> to boot a FreeBSD guest that uses the Xen paravirtual network drivers. >> Decoupling the Xen PV guest support from the hypervisor really >> simplifies deployment. >> >> The current implementation doesn't yet support KVM, as KVM has to >> handle a Xen-specific MSR in order to map hypercall pages into the >> guest physical address space. A recent thread on this list discussed >> the issue but didn't come to a resolution. >> >> Does it make sense to implement a generic mechanism for handling MSRs >> in userspace? I imagine a mechanism analogous to PIO, adding a >> KVM_EXIT_MSR code and a msr type in the kvm_run struct. >> >> I'm happy to take a stab at implementing this if no one else is >> already working on it. > > I think it's a great idea. > I was thinking of doing something similar for ppc's HIDs/SPRs too, so > a userspace app can complement the kernel's vcpu support. > > Also by falling back to userspace all those MSR read/write patches I > send wouldn't have to go in-kernel anymore :) I'm wary of this. It spreads the burden of implementing the cpu emulation across the kernel/user boundary. We don't really notice with qemu as userspace, because we have a cpu emulator on both sides, but consider an alternative userspace that only emulates devices and has no cpu emulation support. We want to support that scenario well. Moreover, your patches only stub out those MSRs. As soon as you implement the more interesting bits, you'll find yourself back in the kernel. I agree however that the Xen hypercall page protocol has no business in kvm.ko. But can't we implement it in emu? Xenner conveniently places a ring 0 stub in the guest, we could trap the MSR there and emulate it entirely in the guest. -- error compiling committee.c: too many arguments to function