From: Joao Martins Subject: Re: [PATCH RFC 01/39] KVM: x86: fix Xen hypercall page msr handling Date: Fri, 22 Feb 2019 11:47:41 +0000 Message-ID: References: <20190220201609.28290-1-joao.m.martins@oracle.com> <20190220201609.28290-2-joao.m.martins@oracle.com> <20190222013008.GG7224@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ankur Arora , Boris Ostrovsky , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org To: Sean Christopherson Return-path: In-Reply-To: <20190222013008.GG7224@linux.intel.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 2/22/19 1:30 AM, Sean Christopherson wrote: > On Wed, Feb 20, 2019 at 08:15:31PM +0000, Joao Martins wrote: >> Xen usually places its MSR at 0x4000000 or 0x4000200 depending on >> whether it is running in viridian mode or not. Note that this is not >> ABI guaranteed, so it is possible for Xen to advertise the MSR some >> place else. >> >> Given the way xen_hvm_config() is handled, if the former address is >> selected, this will conflict with HyperV's MSR >> (HV_X64_MSR_GUEST_OS_ID) which uses the same address. > > Unconditionally servicing Hyper-V and KVM MSRs seems wrong, i.e. KVM > should only expose MSRs specific to a hypervisor if userspace has > configured CPUID to advertise support for said hypervisor. > Yeah, that makes sense. > If we do the > same thing for Xen, then the common MSR code looks like: > > if (kvm_advertise_kvm()) { > if () > return ...; > } else if (kvm_advertise_hyperv()) { > if () > return ...; > } else if (kvm_advertise_xen()) { > if () > return ...; > } > > > > Obviously assumes KVM only advertises itself as one hypervisor, and so > the ordering is arbitrary. > One thing to consider on the above is that there might be multiple hypervisors in advertised in the hypervisor leaf. Which is used when you want to run a KVM guest but with Hyper-V drivers, or an Hyper-V guest with KVM extensions or VirtIO. The else part would probably need to be removed as IIUC when multiple hypervisors are advertised (e.g. KVM in leaf 0x40000000, Hyper-V in leaf 0x40000100) you are still allowed to use all of its features.