Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp437039imm; Thu, 6 Sep 2018 05:03:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZozn2rcCpOO4Ylr9a6MasxozHl5omfnOOQ4bUsg3OvJlIyElZjMPgA1cinJ4ZX5lWWLEBp X-Received: by 2002:a63:fc07:: with SMTP id j7-v6mr2345533pgi.1.1536235400701; Thu, 06 Sep 2018 05:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536235400; cv=none; d=google.com; s=arc-20160816; b=hcoQddiXwe6m4mzvfpvKbaazB4opP+DxdPk3Zr+qzIIL1da73VXP7c9zfFJpRcgKCq S5EpKDtL2upIzJKpvbvy7NUs7DK9TBLeb+sF0XSoHDvJxzuY71M7VhueMyx4XwNLiXRg IXwFyTkjBXylP7wNzerRDitUfqdcLM6xgtFJPoHUYtri1RL6wpXoUL/rnUZ8H2J8bl8Q c9MQI2E7avX0wjLGOoFgSE+trjXPoJZpO/lQlvKmxbITI+3DU4heLdAo2rz84SkzWCky vfIfKqjuKKM5k4p+yYtIozSuOx++Lkplu8SQuWGLMB8ityQTj4MxsFIwxbj9pV9W48kR FdqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=3f1ZoHSibtWhVlE3Z20wTU2xUBm1+96wSY/drsXe4Zg=; b=SKpt8P4zt7FCG03HX8lvzWM8hJBM9jzZ/X0jm0n0gFY5IIZsbcsoYryyrsOJOdqWr3 ypW30X7iB8wid8eZGPiq0ha4NbRR3MBT2yx+rBl9gvlXyOJRhkB8KatbI4Yx3AcBnvjm JEfRiBe8Wk3KBcxDNXr+SBDhd9fe1dp/xpvyKF0NWxjT1y3ef7ZUf9G/G2kB6rK5U9II tr92olJpETsXkbYwbRLr/UoyHd5n5e2nn+QYFb2kphErZPG4UTo/3JxAnai17Y+rho6+ Y9opGOj59cF4ihQDZmMC0a0EtOT7dvaWZ6tdXxtSF9RsPqiKcUstBeJQHFa8WPuMOdK2 usmw== 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 d24-v6si5136103pgb.226.2018.09.06.05.03.05; Thu, 06 Sep 2018 05:03:20 -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 S1728435AbeIFQgl (ORCPT + 99 others); Thu, 6 Sep 2018 12:36:41 -0400 Received: from mga18.intel.com ([134.134.136.126]:62802 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbeIFQgS (ORCPT ); Thu, 6 Sep 2018 12:36:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 05:01:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,338,1531810800"; d="scan'208";a="71046834" Received: from devel-ww.sh.intel.com ([10.239.48.110]) by orsmga008.jf.intel.com with ESMTP; 06 Sep 2018 05:00:58 -0700 From: Wei Wang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, ak@linux.intel.com Cc: kan.liang@intel.com, peterz@infradead.org, mingo@redhat.com, rkrcmar@redhat.com, like.xu@intel.com, wei.w.wang@intel.com Subject: [PATCH v2 5/8] KVM/x86: enable the guest to access the debugctl msr Date: Thu, 6 Sep 2018 19:30:53 +0800 Message-Id: <1536233456-12173-6-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536233456-12173-1-git-send-email-wei.w.wang@intel.com> References: <1536233456-12173-1-git-send-email-wei.w.wang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The debugctl MSR is not completely identical on AMD and Intel CPUs, for example, FREEZE_LBRS_ON_PMI is supported by Intel CPUs only. svm.c has handled the access to the debugctl msr, and this patch handles the access to the debugctl msr on Intel CPUs in vmx.c. Accordingly, the common debugctl msr handling code in kvm_get/set_msr_common is removed. Signed-off-by: Like Xu Signed-off-by: Wei Wang Cc: Paolo Bonzini Cc: Andi Kleen --- arch/x86/kvm/vmx.c | 15 +++++++++++++++ arch/x86/kvm/x86.c | 13 ------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d5eba8e..d0ea360 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4093,6 +4093,11 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) return 1; msr_info->data = to_vmx(vcpu)->arch_capabilities; break; + case MSR_IA32_DEBUGCTLMSR: + if (!vcpu->kvm->arch.guest_lbr) + return 1; + msr_info->data = vmcs_read64(GUEST_IA32_DEBUGCTL); + break; case MSR_IA32_SYSENTER_CS: msr_info->data = vmcs_read32(GUEST_SYSENTER_CS); break; @@ -4266,6 +4271,16 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) return 1; vmx->arch_capabilities = data; break; + case MSR_IA32_DEBUGCTLMSR: + if (!vcpu->kvm->arch.guest_lbr) + return 1; + /* + * Currently, only FREEZE_LBRS_ON_PMI and DEBUGCTLMSR_LBR are + * supported. + */ + data &= (DEBUGCTLMSR_FREEZE_LBRS_ON_PMI | DEBUGCTLMSR_LBR); + vmcs_write64(GUEST_IA32_DEBUGCTL, data); + break; case MSR_IA32_CR_PAT: if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) { if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data)) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 3eaf1b8..4bbb9eb 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2369,18 +2369,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) return 1; } break; - case MSR_IA32_DEBUGCTLMSR: - if (!data) { - /* We support the non-activated case already */ - break; - } else if (data & ~(DEBUGCTLMSR_LBR | DEBUGCTLMSR_BTF)) { - /* Values other than LBR and BTF are vendor-specific, - thus reserved and should throw a #GP */ - return 1; - } - vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n", - __func__, data); - break; case 0x200 ... 0x2ff: return kvm_mtrr_set_msr(vcpu, msr, data); case MSR_IA32_APICBASE: @@ -2623,7 +2611,6 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) switch (msr_info->index) { case MSR_IA32_PLATFORM_ID: case MSR_IA32_EBL_CR_POWERON: - case MSR_IA32_DEBUGCTLMSR: case MSR_IA32_LASTBRANCHFROMIP: case MSR_IA32_LASTBRANCHTOIP: case MSR_IA32_LASTINTFROMIP: -- 2.7.4