From patchwork Mon Mar 10 08:48:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Jinsong" X-Patchwork-Id: 3801701 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C5F4BBF540 for ; Mon, 10 Mar 2014 08:48:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C0832024D for ; Mon, 10 Mar 2014 08:48:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21E412023F for ; Mon, 10 Mar 2014 08:48:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752138AbaCJIsT (ORCPT ); Mon, 10 Mar 2014 04:48:19 -0400 Received: from mga02.intel.com ([134.134.136.20]:9061 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751675AbaCJIsS convert rfc822-to-8bit (ORCPT ); Mon, 10 Mar 2014 04:48:18 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 10 Mar 2014 01:48:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,622,1389772800"; d="scan'208,223";a="469460122" Received: from fmsmsx108.amr.corp.intel.com ([10.19.9.228]) by orsmga001.jf.intel.com with ESMTP; 10 Mar 2014 01:48:17 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.19.17.221) by FMSMSX108.amr.corp.intel.com (10.19.9.228) with Microsoft SMTP Server (TLS) id 14.3.123.3; Mon, 10 Mar 2014 01:48:16 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx152.amr.corp.intel.com (10.19.17.221) with Microsoft SMTP Server (TLS) id 14.3.123.3; Mon, 10 Mar 2014 01:48:16 -0700 Received: from shsmsx152.ccr.corp.intel.com ([169.254.6.130]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.133]) with mapi id 14.03.0123.003; Mon, 10 Mar 2014 16:48:16 +0800 From: "Liu, Jinsong" To: Paolo Bonzini , "'kvm@vger.kernel.org'" , "'linux-kernel@vger.kernel.org'" , "'qemu-devel@nongnu.org'" Subject: [PATCH] KVM: x86: Work around buggy MPX platform Thread-Topic: [PATCH] KVM: x86: Work around buggy MPX platform Thread-Index: Ac88PXlfQ4/brVIqQkCnTIGrpxnr+Q== Date: Mon, 10 Mar 2014 08:48:15 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 5854070994c5002b3a37577165ed3e82f36f712d Mon Sep 17 00:00:00 2001 From: Liu Jinsong Date: Sat, 8 Mar 2014 04:40:02 +0800 Subject: [PATCH] KVM: x86: Work around buggy MPX platform Work around buggy MPX platform which support MSR_IA32_BNDCFGS but has issue at, say, VMX ucode. Signed-off-by: Liu Jinsong --- arch/x86/kvm/x86.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1e91a24..1fc184d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3936,6 +3936,16 @@ static void kvm_init_msr_list(void) for (i = j = KVM_SAVE_MSRS_BEGIN; i < ARRAY_SIZE(msrs_to_save); i++) { if (rdmsr_safe(msrs_to_save[i], &dummy[0], &dummy[1]) < 0) continue; + + /* + * Work around some buggy MPX platform which support + * MSR_IA32_BNDCFGS but has issue at, say, VMX ucode. + */ + if ((msrs_to_save[i] == MSR_IA32_BNDCFGS) && + (kvm_x86_ops->mpx_supported ? + !kvm_x86_ops->mpx_supported() : 1)) + continue; + if (j < i) msrs_to_save[j] = msrs_to_save[i]; j++; @@ -5576,9 +5586,11 @@ int kvm_arch_init(void *opaque) goto out_free_percpu; kvm_set_mmio_spte_mask(); - kvm_init_msr_list(); kvm_x86_ops = ops; + + kvm_init_msr_list(); + kvm_mmu_set_mask_ptes(PT_USER_MASK, PT_ACCESSED_MASK, PT_DIRTY_MASK, PT64_NX_MASK, 0);