From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEHHJ-00083T-Ng for qemu-devel@nongnu.org; Mon, 04 Aug 2014 08:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEHHA-0007wK-MB for qemu-devel@nongnu.org; Mon, 04 Aug 2014 08:22:13 -0400 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:39941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEHHA-0007wE-FV for qemu-devel@nongnu.org; Mon, 04 Aug 2014 08:22:04 -0400 Received: by mail-wi0-f179.google.com with SMTP id f8so4930609wiw.6 for ; Mon, 04 Aug 2014 05:22:03 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53DF7AE8.2010302@redhat.com> Date: Mon, 04 Aug 2014 14:22:00 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Question of emulation on MSR's in KVM-mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Morty Andersen , qemu-devel@nongnu.org Il 04/08/2014 10:37, Morty Andersen ha scritto: > Hi > > I'm working on an extension to QEMU (target i386). This involves adding > new MSR's. I've got it working in non-KVM mode by adding these MSR's to > the state and adding extra cases to helper_wrmsr(), helper_rdmsr(). The > guest can now read/write these MSR's as expected. However, it fails when > running in KVM-mode. Specifically, writing the MSR's causes GPF. Note > that these MSR's are not natively supported by the host CPU. I don't > know enough about Intel's VMX to tell if it is even reasonable to expect > that this could work for a non-natively supported MSR. As far as I can > read in the VMX documentation, the hypervisor can setup a bitmap of > which MSR's should cause trap's to the hypervisor and which shouldn't. I > guess it would be the KVM kernel module that does this based on input it > receives from QEMU. But I haven't been able to find the part of QEMU > that negotiates this. I guess the solution for me is to set the > necessary bits to that access to the new MSR's causes traps. Next, I > need to add/modify the trap handler so that it can handle the MSR's. Hi, handling of the MSRs in KVM is done entirely in the hypervisor. QEMU only gets/sets them in order to support migration. You need to modify the KVM kernel module for the VM to recognize your special MSRs. Paolo