From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Question about guest MSR loading/saving (Intel) Date: Thu, 04 Feb 2010 21:12:37 +0200 Message-ID: <4B6B1C25.2060304@redhat.com> References: <0910BB5A-E4FA-4085-978E-D6374A1376B7@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm To: Kurt Kiefer Return-path: Received: from mx1.redhat.com ([209.132.183.28]:38461 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757891Ab0BDTMs (ORCPT ); Thu, 4 Feb 2010 14:12:48 -0500 In-Reply-To: <0910BB5A-E4FA-4085-978E-D6374A1376B7@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 02/02/2010 03:57 AM, Kurt Kiefer wrote: > Hi all, > > This is a vague/general question. For some background: I have a reason > (control of IA32_PERF_GLOBAL_CTRL) for loading/saving MSRs on > VM-entry/exit. To get this to work correctly, I made changes to use > the conventional VMX MSR load areas of the VMCS for this particular > MSR. Works great. > > Is there a particular reason why MSRs are currently loaded/saved > through KVM's unconventional facilities (vmx.c:save_msrs(), > vmx.c:load_msrs()), rather than through VM entry/exit MSR load regions > in the VMCS? I see that only long mode guests on x86_64 are effected > by this. > > Any insight could be useful. Do you think MSR loading via VMCS would > be faster? Are there downsides to doing it one way or the other? kvm doesn't switch msrs on every entry/exit. For example, the syscall msrs are only used by the syscall/sysret instructions, so we only switch them before returning to userspace, which happens much less frequently than vmexits. The PMU is used by the processor at all times, so it makes perfect sense to use the vmx autoload/autosave regions for that. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.