Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp879595imj; Fri, 15 Feb 2019 08:17:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IbR1hYfhNvi4oj5gNvqEFSVWI8aPa4NFqXEkn2eG6Kdmre/Mwr05AxG5/n6+JDSXlg75FGK X-Received: by 2002:a63:d34a:: with SMTP id u10mr6209269pgi.301.1550247445985; Fri, 15 Feb 2019 08:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550247445; cv=none; d=google.com; s=arc-20160816; b=ZCGlCbWhZG9A881oRYP4eV1Pffh4BjD2Mjy+J7XxFjfj1I9BrKvDRFlAYENPFPiTMo N3kKRdCbm61l+N3ishlqjhWP2zNSff+Ll+3svpy4YmvmvGSu0GEi5UJVNKEiUC86/ySC lw7Q0avsYqHbuwoHlQKGBeJRQ+CmP8nslHizpyRvxXpdNojSIaAmEDuykG/JNAnNa1kR X/Xoqi6Vmfpo6teEQxqi6N2EeD5ezFvz7nLdyd5Bf41TDC/4L+T8y5zkh5BVcGjwU32p /NEhUXqqCfP6kUlheWi+Hm0lhfx6eDKfVnJs5tcwROe2xqsTiGQa8RYuzkxlPVRUBp78 kdNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=jTxjL5TjCHfaeU0ZTAzO4DyRD/zhXxMjh1RVfP43a7s=; b=VbtggHFXs7EBtyb2Dae7pHog3O2kdQ0x/n7/exn601ko7vit+Z1BPk926ItiBoAl8K SC1wGA6siAO6fsiC59pjBB2bdTuUdQWcfPNeMBTF2XBJGkVExuJMng/PglV0jASfO8Pn jGima6/VL1S3PxtpcGaolp4GsLV2u2m24xZRtk0R8LAElvU9UKxn3YogetdAkODjuAeq NYt2rS+Lvy/Qxey+Pno+zfez+e+TPs0CtjLomIIkyZpwujJEfiBpbAPNNLYhXaMhu4a7 YIUiQ3LWYWVPDoVbBEbq3Mg4VrYXpLl3KshUsHha8PoUlq7wSGQb6tPNXPHHJCt/vdyb VbkQ== 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 x1si793486plr.439.2019.02.15.08.17.09; Fri, 15 Feb 2019 08:17:25 -0800 (PST) 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 S2437028AbfBONKR (ORCPT + 99 others); Fri, 15 Feb 2019 08:10:17 -0500 Received: from mga17.intel.com ([192.55.52.151]:2647 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbfBONKR (ORCPT ); Fri, 15 Feb 2019 08:10:17 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2019 05:10:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,372,1544515200"; d="scan'208";a="275317145" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by orsmga004.jf.intel.com with ESMTP; 15 Feb 2019 05:10:15 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id EF062300E42; Fri, 15 Feb 2019 05:10:14 -0800 (PST) Date: Fri, 15 Feb 2019 05:10:14 -0800 From: Andi Kleen To: "Wang, Wei W" Cc: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "peterz@infradead.org" , "Liang, Kan" , "mingo@redhat.com" , "rkrcmar@redhat.com" , "Xu, Like" , "jannh@google.com" , "arei.gonglei@huawei.com" , "jmattson@google.com" Subject: Re: [PATCH v5 12/12] KVM/VMX/vPMU: support to report GLOBAL_STATUS_LBRS_FROZEN Message-ID: <20190215131014.GC16922@tassilo.jf.intel.com> References: <1550135174-5423-1-git-send-email-wei.w.wang@intel.com> <1550135174-5423-13-git-send-email-wei.w.wang@intel.com> <20190214163147.GL16922@tassilo.jf.intel.com> <286AC319A985734F985F78AFA26841F73DF71ED6@shsmsx102.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <286AC319A985734F985F78AFA26841F73DF71ED6@shsmsx102.ccr.corp.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 15, 2019 at 08:56:02AM +0000, Wang, Wei W wrote: > On Friday, February 15, 2019 12:32 AM, Andi Kleen wrote: > > > > > +static void intel_pmu_get_global_status(struct kvm_pmu *pmu, > > > + struct msr_data *msr_info) > > > +{ > > > + u64 guest_debugctl, freeze_lbr_bits = > > DEBUGCTLMSR_FREEZE_LBRS_ON_PMI | > > > + DEBUGCTLMSR_LBR; > > > + > > > + if (!pmu->global_status) { > > > + msr_info->data = 0; > > > + return; > > > + } > > > + > > > + msr_info->data = pmu->global_status; > > > + if (pmu->version >= 4) { > > > + guest_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); > > > + if ((guest_debugctl & freeze_lbr_bits) == freeze_lbr_bits) > > > > It should only check for the freeze bit, the freeze bit can be set even when > > LBRs are disabled. > > > > Also you seem to set the bit unconditionally? > > That doesn't seem right. It should only be set after an overflow. > > > > So the PMI injection needs to set it. > > OK. The freeze bits need to be cleared by IA32_PERF_GLOBAL_STATUS_RESET, which seems not supported by the perf code yet (thus guest won't clear them). Would handle_irq_v4 also need to be changed to support that? In Arch Perfmon v4 it is cleared by the MSR_CORE_PERF_GLOBAL_OVF_CTRL write But the guest KVM pmu doesn't support v4 so far, so the only way to clear it is through DEBUGCTL. STATUS_RESET would only be needed to set it from the guest, which is not necessary at least for now (and would be also v4) At some point the guest PMU should probably be updated for v4, but it can be done separately from this. -Andi