Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp286420pxj; Fri, 14 May 2021 03:30:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaYqCMe1n9IN8Q6q07Omlw/+ubakCcM0xPFvyvWluvzuuDFcFDRZNljdDHz/WsWanUaX7m X-Received: by 2002:a6b:c84f:: with SMTP id y76mr34534054iof.23.1620988254482; Fri, 14 May 2021 03:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620988254; cv=none; d=google.com; s=arc-20160816; b=bPz40TyB5ZlmvCA1nMlkrjovRG7GppmP8JgDoKvzIFJJgCOrdYzdynzmoUg0FD7D1L cfwAzVvDLR6qDOVzxqgZLd0bjyN+q80gkpiGjMWOb9Tw+0HSyzSdXI7zxvDYnvytkcBl 0k/7i1CkCVbE8aA8YIcW0AJyIFbAxOvRuHHT/YLjU9bsq+INblYfdDZM6YcCIvM4NQCZ 4UIsc2FwOaotj8Mnl91O+Y/jNMHIQ+Rt73WDlT7/ZZAdEeuBAdrHTP9QWyjyIlpTb5Jw yXmviMo2hhMsO0hSmc8yySHocVzYtuVno7VjpVcHb4HKqkU8GVlAeTXupi83B1l6DChU w6qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=KSuLsNK9yLdyKvHxl3UCrd7PzaXpYQDJCoExv6e0j3w=; b=wCCjHlig/KLP07r9NObpkUUinDozG7PMdvB2IRpmn2opJEDRr1rTWpOVGsYTnFlgH+ KS2c7xO3xJMwBpyKFEYpCjFSfsGUOXYBoALG2Uo2XIucekb3aT7HqN9NjqtoH+HT/sdu n8fOxv3Eq9xc8YJnbXWu/aRqcn0LjCiaRzwYM5+xM0hLdUXBU0DzYLRopvzXPZjJKifX udpeSsutDN84JliA6ey12PGwEgDLp763LOEOJJsT+RZotVf5DKYb1FYbDr3BvwAm7Pj7 4UAEYO/PLVfGhLxQHL42vstvYJAWPtbfSu3ZhwPO6h45zHHMG03IWHQ1LF2LPvuSGNAf DLvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u24si6836516iom.67.2021.05.14.03.30.42; Fri, 14 May 2021 03:30:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233692AbhENIqn (ORCPT + 99 others); Fri, 14 May 2021 04:46:43 -0400 Received: from mga06.intel.com ([134.134.136.31]:2925 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231839AbhENIqn (ORCPT ); Fri, 14 May 2021 04:46:43 -0400 IronPort-SDR: l4e5DGRN86ONAeZfXa6utUVo8amSBRPu8oKaJbFwxl80CBXD5WhiV3RWRkwBcqThd5ZaxAq4LS o9e3xItDLUMQ== X-IronPort-AV: E=McAfee;i="6200,9189,9983"; a="261379995" X-IronPort-AV: E=Sophos;i="5.82,299,1613462400"; d="scan'208";a="261379995" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2021 01:45:31 -0700 IronPort-SDR: GWVlx1jD/WhhKk0Pyewb9aPU/D6oWp9TNtglPJKLRhY1pr62N0XD6c5OWGIz0W5r7jqP3JmbpJ u4RpKUnL1Dqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,299,1613462400"; d="scan'208";a="538739299" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by fmsmga001.fm.intel.com with ESMTP; 14 May 2021 01:45:28 -0700 From: Like Xu To: Paolo Bonzini Cc: Alexander Shishkin , Peter Zijlstra , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Like Xu Subject: [PATCH] KVM: x86/pt: Do not inject TraceToPAPMI when guest PT isn't supported Date: Fri, 14 May 2021 16:44:36 +0800 Message-Id: <20210514084436.848396-1-like.xu@linux.intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a PT perf user is running in system-wide mode on the host, the guest (w/ pt_mode=0) will warn about anonymous NMIs from kvm_handle_intel_pt_intr(): [ 18.126444] Uhhuh. NMI received for unknown reason 10 on CPU 0. [ 18.126447] Do you have a strange power saving mode enabled? [ 18.126448] Dazed and confused, but trying to continue In this case, these PMIs should be handled by the host PT handler(). When PT is used in guest-only mode, it's harmless to call host handler. Fix: 8479e04e7d("KVM: x86: Inject PMI for KVM guest") Signed-off-by: Like Xu --- arch/x86/events/intel/core.c | 3 +-- arch/x86/kvm/x86.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 2521d03de5e0..2f09eb0853de 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2853,8 +2853,7 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status) if (unlikely(perf_guest_cbs && perf_guest_cbs->is_in_guest() && perf_guest_cbs->handle_intel_pt_intr)) perf_guest_cbs->handle_intel_pt_intr(); - else - intel_pt_interrupt(); + intel_pt_interrupt(); } /* diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6529e2023147..6660f3948cea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8087,6 +8087,9 @@ static void kvm_handle_intel_pt_intr(void) { struct kvm_vcpu *vcpu = __this_cpu_read(current_vcpu); + if (!guest_cpuid_has(vcpu, X86_FEATURE_INTEL_PT)) + return; + kvm_make_request(KVM_REQ_PMI, vcpu); __set_bit(MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI_BIT, (unsigned long *)&vcpu->arch.pmu.global_status); -- 2.31.1