From patchwork Fri Jan 25 19:01:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 1031256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43mT0l6pwMz9sD9 for ; Sat, 26 Jan 2019 06:02:14 +1100 (AEDT) Received: from localhost ([127.0.0.1]:49424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn6jy-0001gt-Ai for incoming@patchwork.ozlabs.org; Fri, 25 Jan 2019 14:02:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn6jY-0001gk-LR for qemu-devel@nongnu.org; Fri, 25 Jan 2019 14:01:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gn6jX-0001gV-Pw for qemu-devel@nongnu.org; Fri, 25 Jan 2019 14:01:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gn6jX-0001fH-KB for qemu-devel@nongnu.org; Fri, 25 Jan 2019 14:01:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42D437AEAB; Fri, 25 Jan 2019 19:01:40 +0000 (UTC) Received: from localhost (ovpn-116-63.gru2.redhat.com [10.97.116.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0678484ED; Fri, 25 Jan 2019 19:01:36 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2019 17:01:34 -0200 Message-Id: <20190125190134.25492-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 25 Jan 2019 19:01:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] i386: Disable MSR_PLATFORM_INFO emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , kvm@vger.kernel.org, Marcelo Tosatti , Maxime Coquelin , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Linux v4.12 introduced[1] emulation of MSR_PLATFORM_INFO and MSR_MISC_FEATURES_ENABLES, and enabled the MSR_PLATFORM_INFO_CPUID_FAULT bit unconditionally. This made guests incorrectly believe the VM emulates MSR_MISC_FEATURES_ENABLES properly (which is not true because QEMU has no migration code to handle the MSR). The KVM_CAP_MSR_PLATFORM_INFO capability was added[2] to Linux v4.19 to address the issue. Use it to disable emulation of MSR_PLATFORM_INFO and stop incorrectly exposing cpuid_fault to guests. References: [1] commit db2336a80489 ("KVM: x86: virtualize cpuid faulting") [2] commit 6fbbde9a1969 ("KVM: x86: Control guest reads of MSR_PLATFORM_INFO") Reported-by: Maxime Coquelin Signed-off-by: Eduardo Habkost --- target/i386/kvm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 9af4542fb8..9629f25c90 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1647,6 +1647,14 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } + /* + * QEMU doesn't initialize MSR_PLATFORM_INFO yet, so disable the MSR + * unconditionally until support for the MSR is properly implemented + */ + if (kvm_check_extension(s, KVM_CAP_MSR_PLATFORM_INFO)) { + kvm_vm_enable_cap(s, KVM_CAP_MSR_PLATFORM_INFO, 0); + } + return 0; }