Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2987967img; Mon, 25 Mar 2019 01:08:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOOA4h/rc9n5Mz6gMNE+Cr9mnnCGhOn8q1fu8Y/EvBzHKvysIwo0XsOeX1qsgsu62F07e9 X-Received: by 2002:a17:902:b217:: with SMTP id t23mr24238654plr.184.1553501287575; Mon, 25 Mar 2019 01:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553501287; cv=none; d=google.com; s=arc-20160816; b=FqpVtre+xloKc496S44KgPPrG+/NLJsvFsZKVVmSq2IFJJ4Ko4c6RwSbVkzaLSOMJ8 fDEnObzS+hWdrrylmno20QDxpvq2CKIDbO436ID7L4Wrek4dDarbTaL669tFlmrNBkvh 8LRVvVpZ4hHrBFnQHL/ZhsCVt3nx1/YNjLO113oogXjq4pU21NcpXmzylxEUtppFhazF cSw2hvQSUkQY67rKLvFoy3sbOwZ20icKrMmO9IKttssQCdewm7Y/Sg9SDxMoerPGOA2W By/udAYmVc9HY3MfsEsn1uVHW8EaSEwgIdUBnuvDfMDbFUblNPEw+osbGwqdC5MmzCyM TTKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=9IqQ2kAyoTiiXnKgHXx0IMXvUSL+hoYbvJaZuf4moNU=; b=p87PQgOrTh+wNSVoOauEFNCz93ZnZ1c6OdsSLRCoCKH2nffl/jXZkttUX4pTSxrcH6 hEjTpnPt8kxKHhwfywKNioOeFlOee4U1lxVrgD72gG23xK+o/9vs1p/+H23PUHfthmOr POdYSZ4MxUu/NqWr7/pXI4uHm6G2Iylzz1NGOFg0K8jux0bu9ErUvZ+3u6xY22GUps0R hTASgcGklgKNQHaElWj/A3d9GdEF3RzycWc2gZsnpy7xW5ZK0tP/rTZF8317/b1jNCRV AfGX25I+GFA84eFbb81UZ8GXsWJv576Eqz8gudfg2eomo5SyNHxOLjfkffEncbI8TRjc eaEA== 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 b8si13342509plr.54.2019.03.25.01.07.52; Mon, 25 Mar 2019 01:08:07 -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 S1729944AbfCYIHO (ORCPT + 99 others); Mon, 25 Mar 2019 04:07:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:50930 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729828AbfCYIHO (ORCPT ); Mon, 25 Mar 2019 04:07:14 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Mar 2019 01:07:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="134474058" Received: from lxy-server.sh.intel.com ([10.239.48.11]) by fmsmga008.fm.intel.com with ESMTP; 25 Mar 2019 01:07:11 -0700 From: Xiaoyao Li To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Xiaoyao Li , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, chao.gao@intel.com, Sean Christopherson Subject: [PATCH v3 0/2] Switch MSR_MISC_FEATURES_ENABLES and one optimization Date: Mon, 25 Mar 2019 16:06:48 +0800 Message-Id: <20190325080650.19896-1-xiaoyao.li@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Patch 1 switches MSR_MISC_FEATURES_ENABLE between host and guest to avoid cpuid faulting and ring3mwait of host leaking to guest. Because cpuid faulting eanbled in host may potentially cause guest boot failure, and kvm doesn't expose ring3mwait to guest yet, it should be leaked to guest. Patch 2 optimizes the switch of MSR_MISC_FEATURES_ENABLES by avoiding WRMSR whenever possible to save cycles. ==changelog== v2->v3: - use msr_misc_features_shadow instead of reading hardware msr, from Sean Christopherson - avoid WRMSR whenever possible, from Sean Christopherson. v1->v2: - move the save/restore of cpuid faulting bit to vmx_prepare_swich_to_guest/vmx_prepare_swich_to_host to avoid every vmentry RDMSR, based on Paolo's comment. Xiaoyao Li (2): kvm/vmx: Switch MSR_MISC_FEATURES_ENABLES between host and guest x86/vmx: optimize MSR_MISC_FEATURES_ENABLES switch arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kernel/process.c | 1 + arch/x86/kvm/vmx/vmx.c | 31 +++++++++++++++++++++++++++++++ arch/x86/kvm/x86.c | 15 ++++++++++++--- 4 files changed, 46 insertions(+), 3 deletions(-) -- 2.19.1