Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1752374ybg; Sun, 27 Oct 2019 04:13:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPLPfkEFwpKK0v0IagCk32y9uK1eAAcUR/S0Q9m8PHoPuD1yVQ7tB4QvZy59cGcDwWyur7 X-Received: by 2002:a17:907:20f3:: with SMTP id rh19mr10400969ejb.289.1572174837252; Sun, 27 Oct 2019 04:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572174837; cv=none; d=google.com; s=arc-20160816; b=q0zeO1QxhHv6I+Mp4CXzkFd2033Rj5+lvGSp+pBIIkPxEyyR4GGJoOSk1k+31maaHX VEGg4u47kNkz1WWAqPe2k8OKz+/yBAyjfby9QBDAzy1XBqVwjKEzOj1lsCHTmXOOqpkT C2WigSk1XDAiykhyg2TmllKPStvCZm9Led8KKSr3Qewd1j2z6uBefeKjVSZbqPiayhxF Nyy+PqiUiXj42hdWbqyBj3kT2PPBUfQdvYwNW0q/gqpjEL8NBaASHbbQbDd+DqEn6b3O Q79bSWQQZw1ded5bFHMJzpsWgRPHenujnBarwUq20laDrVBOE2F1JITaa7LaqTrclKJi xKKg== 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=9rI+cYuDb4jcKzsYdEMAXdtxhoR4Ri9Dihm03WPzx+c=; b=vQuljvrbksmSEGHqHIw9jCrQWbApYNdt/5XgPvkrm2IOrNjYKmcjzKqnd6ko6DqKOc 3IUs0yIbNuyyIatOvX+INiuKLwGV85E15CQ4pRW2Wg8hayeIFxJtu4OBhcyiC0GSKNpG 2O61HWqf7g2t94nHwDBVUQ4XoYPROpbk/m3OhuJ7z1CcJrOfQElfUeAQngf1u/SIP+72 35PE8LKOoe6lzUB83GXWlbNZ6i3t51AoA5Vogbi9H/ykg8PJc3edDSkJe6LEkAkdVzgk mzFp+RinL8w8eHjmF1YVPydse4PykwaMYhJ+H9J70g653lpEp/No34vytrRwBb/yZ0Om 7rgg== 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 gf8si4384109ejb.236.2019.10.27.04.13.34; Sun, 27 Oct 2019 04:13:57 -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 S1726899AbfJ0LMp (ORCPT + 99 others); Sun, 27 Oct 2019 07:12:45 -0400 Received: from mga02.intel.com ([134.134.136.20]:12497 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbfJ0LMm (ORCPT ); Sun, 27 Oct 2019 07:12:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Oct 2019 04:12:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,236,1569308400"; d="scan'208";a="282690172" Received: from unknown (HELO snr.jf.intel.com) ([10.54.39.141]) by orsmga001.jf.intel.com with ESMTP; 27 Oct 2019 04:12:40 -0700 From: Luwei Kang To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, ak@linux.intel.com, thomas.lendacky@amd.com, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, Luwei Kang Subject: [PATCH v1 6/8] KVM: X86: MSR_IA32_PERF_CAPABILITIES MSR emulation Date: Sun, 27 Oct 2019 19:11:15 -0400 Message-Id: <1572217877-26484-7-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1572217877-26484-1-git-send-email-luwei.kang@intel.com> References: <1572217877-26484-1-git-send-email-luwei.kang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose some bits of definition which relate with enable PEBS to KVM guest especially PEBS via PT feature. Signed-off-by: Luwei Kang --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/include/asm/msr-index.h | 3 +++ arch/x86/kvm/vmx/vmx.c | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index a987ae1..24a0ab9 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -569,6 +569,7 @@ struct kvm_vcpu_arch { u64 ia32_xss; u64 microcode_version; u64 arch_capabilities; + u64 ia32_perf_capabilities; /* * Paging state of the vcpu diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index d22f8d9..75c09e4 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -137,6 +137,9 @@ #define MSR_IA32_PEBS_ENABLE 0x000003f1 #define MSR_PEBS_DATA_CFG 0x000003f2 #define MSR_IA32_DS_AREA 0x00000600 +#define MSR_IA32_PERF_CAP_PEBS_TRAP BIT_ULL(6) +#define MSR_IA32_PERF_CAP_PEBS_ARCH_REG BIT_ULL(7) +#define MSR_IA32_PERF_CAP_PEBS_REC_FMT (0xfULL << 8) #define MSR_IA32_PERF_CAP_PEBS_OUTPUT_PT BIT_ULL(16) #define MSR_IA32_PERF_CAPABILITIES 0x00000345 #define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6 diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 6c29a57..5c4dd05 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1828,6 +1828,16 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) return 1; msr_info->data = vcpu->arch.ia32_xss; break; + case MSR_IA32_PERF_CAPABILITIES: + if (!vmx_pdcm_supported() || !vmx_pebs_supported()) + return 1; + rdmsrl(MSR_IA32_PERF_CAPABILITIES, msr_info->data); + msr_info->data = msr_info->data & + (MSR_IA32_PERF_CAP_PEBS_TRAP | + MSR_IA32_PERF_CAP_PEBS_ARCH_REG | + MSR_IA32_PERF_CAP_PEBS_REC_FMT | + MSR_IA32_PERF_CAP_PEBS_OUTPUT_PT); + break; case MSR_IA32_RTIT_CTL: if (pt_mode != PT_MODE_HOST_GUEST) return 1; @@ -2082,6 +2092,10 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) else clear_atomic_switch_msr(vmx, MSR_IA32_XSS); break; + case MSR_IA32_PERF_CAPABILITIES: + if (!vmx_pdcm_supported() || !vmx_pebs_supported()) + return 1; + break; case MSR_IA32_RTIT_CTL: if ((pt_mode != PT_MODE_HOST_GUEST) || vmx_rtit_ctl_check(vcpu, data) || -- 1.8.3.1