From patchwork Fri Oct 23 09:15:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhoujian (jay)" X-Patchwork-Id: 7471061 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 82636BEEA4 for ; Fri, 23 Oct 2015 09:18:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE60420445 for ; Fri, 23 Oct 2015 09:18:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B93A52041A for ; Fri, 23 Oct 2015 09:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752685AbbJWJRM (ORCPT ); Fri, 23 Oct 2015 05:17:12 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:23276 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751636AbbJWJRJ (ORCPT ); Fri, 23 Oct 2015 05:17:09 -0400 Received: from 172.24.1.51 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.51]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CUY32370; Fri, 23 Oct 2015 17:15:37 +0800 (CST) Received: from localhost (10.177.19.14) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Fri, 23 Oct 2015 17:15:29 +0800 From: Jian Zhou To: , , , , , , , CC: , , , , Jian Zhou Subject: [PATCH v2 1/4] KVM: X86: Add arrays to save/restore LBR MSRs Date: Fri, 23 Oct 2015 17:15:15 +0800 Message-ID: <1445591718-5720-2-git-send-email-jianjay.zhou@huawei.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1445591718-5720-1-git-send-email-jianjay.zhou@huawei.com> References: <1445591718-5720-1-git-send-email-jianjay.zhou@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.14] X-CFilter-Loop: Reflected 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, 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 Add arrays in kvm_vcpu_arch struct to save/restore LBR MSRs at vm exit/entry time. Add new hooks to set/get DEBUGCTLMSR and LBR MSRs. Signed-off-by: Jian Zhou Signed-off-by: Stephen He --- arch/x86/include/asm/kvm_host.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 3a36ee7..dc2c120 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -376,6 +376,12 @@ struct kvm_vcpu_hv { u64 hv_vapic; }; +struct msr_data { + bool host_initiated; + u32 index; + u64 data; +}; + struct kvm_vcpu_arch { /* * rip and regs accesses must go through @@ -516,6 +522,15 @@ struct kvm_vcpu_arch { unsigned long eff_db[KVM_NR_DB_REGS]; unsigned long guest_debug_dr7; + int lbr_status; + int lbr_used; + + struct lbr_msr { + unsigned nr; + struct msr_data guest[MAX_NUM_LBR_MSRS]; + struct msr_data host[MAX_NUM_LBR_MSRS]; + }lbr_msr; + u64 mcg_cap; u64 mcg_status; u64 mcg_ctl; @@ -728,12 +743,6 @@ struct kvm_vcpu_stat { struct x86_instruction_info; -struct msr_data { - bool host_initiated; - u32 index; - u64 data; -}; - struct kvm_lapic_irq { u32 vector; u16 delivery_mode; @@ -887,6 +896,11 @@ struct kvm_x86_ops { gfn_t offset, unsigned long mask); /* pmu operations of sub-arch */ const struct kvm_pmu_ops *pmu_ops; + + int (*set_debugctlmsr)(struct kvm_vcpu *vcpu, u64 value); + u64 (*get_debugctlmsr)(void); + void (*set_lbr_msr)(struct kvm_vcpu *vcpu, u32 msr, u64 data); + u64 (*get_lbr_msr)(struct kvm_vcpu *vcpu, u32 msr); }; struct kvm_arch_async_pf {