Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3539986img; Mon, 25 Mar 2019 12:22:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSvsXvtq7q2elyC1YWKhuTxfWOGE/S9nlXyFqJEhalWPXBYoGjKEK5VGQsKqaIQD3SpD0q X-Received: by 2002:a17:902:b282:: with SMTP id u2mr8214518plr.9.1553541736100; Mon, 25 Mar 2019 12:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553541736; cv=none; d=google.com; s=arc-20160816; b=ukmYgUSSvaLRv+MkxQyK0pcf1F4rZG4njylONWUnp04ImQVv6/c3FIMTNWXdc79mB4 k+ga/29zGVgZe1maUw6ndGuK5bNWsFTOUfDF7C5I5ZXCWWWCf22aV4iVTiI5Lk6okX9/ cT7i03EfLMNNygS10XGAuYa5pnPxQ1D7nVQznwJQvngAg6Hh1WCj/vRdhgnwx7Oad/hI v0jiI2Izyti3y0QY3TKzG3kBL7+fTAX3Mq4EhsnTiI++gzUd3VFWfBcmhUOjU2oCnFy9 OqkOa4303n+XG3Vcp6YnsjQkOUVcPsf16yFPehDrWR/CZYYoBrN2HhPX1ZL81nB97PTr cR6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ls6233HG6IXNH2k8ObOktN8tpiqSEM0+pwqANEdvYpY=; b=kUjpXejpMjcSyOElrnVrH++Z112+S7PstmVk8y9y/+45vlMFKuHVvJx/cETafRf2rW koIGU/Fb6ylPDeXQPCmFUoHEpXYP6YsHsUdfltuDxgFewiBC70FvrLirv4IbSG0n0pmr j07azi0GqP66zSv75Ugw+DP6Om5M+u0cddaNiQ4Uj65m8tj770yrK4Me2kzWu80DBYO3 gkxOKmG+lhQaO5PllW5nGT75ThppSekM9hwMGpvta0Hh+f5fgDrnpZuBRYi2bZhXGJFQ +CyUBbcrqQZpuzCpTvvcRv0q9TM/UymngOwGi/g50pUdsFbIjn/hscN4wNizb9iUBQe5 Iykg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n13si13731148pgq.116.2019.03.25.12.22.00; Mon, 25 Mar 2019 12:22:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729883AbfCYTVN (ORCPT + 99 others); Mon, 25 Mar 2019 15:21:13 -0400 Received: from mga03.intel.com ([134.134.136.65]:19193 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729473AbfCYTVM (ORCPT ); Mon, 25 Mar 2019 15:21:12 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Mar 2019 12:21:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,269,1549958400"; d="scan'208";a="310322464" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by orsmga005.jf.intel.com with ESMTP; 25 Mar 2019 12:21:11 -0700 Date: Mon, 25 Mar 2019 12:21:11 -0700 From: Sean Christopherson To: Borislav Petkov Cc: KVM , Joerg Roedel , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Tom Lendacky , Tony Luck , Yazen Ghannam , LKML Subject: Re: [PATCH 1/2] kvm/x86: Move MSR_K7_HWCR to svm.c Message-ID: <20190325192111.GH31069@linux.intel.com> References: <20190325171649.7311-1-bp@alien8.de> <20190325171649.7311-2-bp@alien8.de> <20190325182133.GG31069@linux.intel.com> <20190325183909.GQ12016@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190325183909.GQ12016@zn.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 25, 2019 at 07:39:09PM +0100, Borislav Petkov wrote: > On Mon, Mar 25, 2019 at 11:21:33AM -0700, Sean Christopherson wrote: > > Won't this prevent emulating an AMD guest on Intel hardware, e.g. due to > > injecting #GPs during boot? > > I guess, but... > > > Keeping support in kvm_{get,set}_msr_common > > doesn't preclude svm_{get,set}_msr() from having SVM-specific handling for > > the MSR. > > ... is kvm_{get,set}_msr_common() supposed to cover for all those > overlapping MSRs between AMD and Intel? svm_{get,set}_msr() have a lot > more AMD-specific MSRs just like vmx_{get,set}_msr() respectively for > Intel. > > Which would mean that if you really want to support those cross-vendor > emulations, you don't need the svm* and vmx* MSR accessors... or am I > missing something? Generally speaking, the goal is to support cross-vendor VMs without having to modify the guest kernel, i.e. exact emulation is out of scope. This means "emulating" cross-vendor MSRs that the guest expects to exist to the point where the guest won't explode, e.g. in the case of MSR_K7_HWCR, Linux expects the MSR to exist on all AMD platforms and AFAICT will die during boot if it doesn't. The rule of thumb for "what MSRs can a guest reasonably expect to exist" is fluid. The most clear cut cases are when support is explicitly enumerated via some feature bit and KVM reports support for said feature to userspace, e.g. if userspace advertises a feature (to the guest) that KVM doesn't support, then it's a userspace bug. But for MSRs like MSR_K7_HWCR and MSR_F10H_DECFG where their existence is implicit, whoever came first often wins. For example, MSR_K7_HWCR existed long before KVM and guest kernels expect it to exist on all AMD CPUs, so KVM emulates it unconditionally. Whereas MSR_F10H_DECFG was recently added and obviously not emulated on existing hypervisors, so the kernel has to assume the MSR might not exist when running under a hypervisor, which means KVM doesn't need to pretend the MSR uncondtionally exists.