Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1961021ioo; Mon, 23 May 2022 07:09:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNh5hYYWSlGr87VI4maDRI0mAArpaGTSk3qWJPnCC0Fr1EYyMV0zBrmAc69wbsN1ziLTdt X-Received: by 2002:a63:fa41:0:b0:3c2:1941:5894 with SMTP id g1-20020a63fa41000000b003c219415894mr20225154pgk.296.1653314963407; Mon, 23 May 2022 07:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653314963; cv=none; d=google.com; s=arc-20160816; b=PQ4O/SgDUMqQe+9Ay8Ka0QimhpJGFHoNNcyfpoIIGFJqg15ybm5C7A2p2WgMR5IP00 Ak5kfBccdVDnGwZnwHRv8xvQlGplxQ7PKKEpuVbJPQ0C5ufuMnSnHnSlzqAhFtc6I7Br RgOq/ZmT+I8s20OPAcxySFJqogKIZSoJ3nm7zJCoJT7TEV+Akk7Nw3dp79kIfFnnqnwk FV0v/OI+nft9PhYB/uLc9RX0gjQZQ2R1aAQ1L4pU3U+BQd1fkpec0vEJSYR+MYDOVJIM d2RG0GiNygyzJiQwqjb9p2nyYX5sZPufnEqFaCqvuUTzs9y0mLYxrzi+/qu7hw0wQtyr JG8Q== 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:dkim-signature; bh=AMxIsslhbyj/A4o1gFHDEGmjLWw+E/bS7wVhQABsku8=; b=TXpl24EuzxxTaVmAZaP7CAAOqkqhUkuPx+BGXxvOKg0nNUQDXwForT1MCtxI0SQp9u ytbHWRXb2v3iNY654CfWbBgVN0Sd8puqsCLPq9HKsbEJq/+pSL+o8Xcl1zCvPhANWvPN kTuSyRt5UxxdS/j/f56va2Twr4CMwdg3DoTNKGNJe/KfAdp1166mFS4vRv3vLnGs+TcA hqN5hFAkKFmvfxkWnoH4Q/L3OyuHP9+LAuc7OXzCcN2lxGJ9VYU+vl5D99ILnKmJ2fV7 lvXXDamK1m68bysAw3ZK4tU8N1EYnxIO/LB81O1XeWnA8eywUQxdRnFSQ1TCRYUDTKpx DVQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TlgaClV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j70-20020a638049000000b003fa247b3520si6748542pgd.444.2022.05.23.07.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 07:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TlgaClV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D8B6D43385; Mon, 23 May 2022 07:09:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236849AbiEWOJE (ORCPT + 99 others); Mon, 23 May 2022 10:09:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236784AbiEWOJD (ORCPT ); Mon, 23 May 2022 10:09:03 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B17C43385; Mon, 23 May 2022 07:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653314942; x=1684850942; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CP8ihjKGx/8QsyN9SA++OSx8EsR3YUJySmWvuEJ3E+Y=; b=TlgaClV7hMQLmBeULz/zHdnutwRbU63nMkLIdeAmEOLfWWnwG0BkJJAo aPMrCy1YSRYkKqG8PRZMTXcXM/1GejCP3R+0OxXm9ZGG2SqxOfLgxwATQ irM4xyqvJxiCwSpLS2wunb2jNf0rwCRUy11MSjW+vfkNiJRtUNQMJ6eFE s/kWaXeN4Ym6FX0UhTv5iRFSoA+Z9iUREX0Xz1xc3Bf7OZ1owTAezuQLs xWUxxD6QZIRVyM08VHY5J7rGX2oPbMCH7f64TB0gQAJp/o7vgFh9k6qA5 OKUqwfLUqUzxr8p+bxX3NRh1Jz776FhB/TSX2QwnzGmyI2lcpLrgrOi18 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="253109280" X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="253109280" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 07:09:01 -0700 X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="558660848" Received: from tower.bj.intel.com ([10.238.157.62]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 07:08:57 -0700 From: Yanfei Xu To: pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, wei.w.wang@intel.com, kan.liang@intel.com Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] KVM: x86: Fix the intel_pt PMI handling wrongly considered from guest Date: Mon, 23 May 2022 22:08:21 +0800 Message-Id: <20220523140821.1345605-1-yanfei.xu@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When kernel handles the vm-exit caused by external interrupts and NMI, it always set a type of kvm_intr_type to handling_intr_from_guest to tell if it's dealing an IRQ or NMI. For the PMI scenario, it could be IRQ or NMI. However the intel_pt PMI certainly is a NMI PMI, hence using kvm_handling_nmi_from_guest() to distinguish if the intel_pt PMI comes from guest is more appropriate. This modification can avoid the host wrongly considered the intel_pt PMI comes from a guest once the host intel_pt PMI breaks the handling of vm-exit of external interrupts. Fixes: db215756ae59 ("KVM: x86: More precisely identify NMI from guest when handling PMI") Signed-off-by: Yanfei Xu --- v1->v2: 1.Fix vmx_handle_intel_pt_intr() directly instead of changing the generic function. 2.Tune the commit message. v2->v3: Add the NULL pointer check of variable "vcpu". arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 610355b9ccce..982df9c000d3 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7856,7 +7856,7 @@ static unsigned int vmx_handle_intel_pt_intr(void) struct kvm_vcpu *vcpu = kvm_get_running_vcpu(); /* '0' on failure so that the !PT case can use a RET0 static call. */ - if (!kvm_arch_pmi_in_guest(vcpu)) + if (!vcpu || !kvm_handling_nmi_from_guest(vcpu)) return 0; kvm_make_request(KVM_REQ_PMI, vcpu); -- 2.32.0