Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3289856lfo; Mon, 23 May 2022 00:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1s1aFgSjxg231GX47VFYLxVnJAudtTIKU80xLNgQS3/cfn3skXwQ+wPBnloAKHHawEz6t X-Received: by 2002:a05:6a00:1ac7:b0:518:ba18:abab with SMTP id f7-20020a056a001ac700b00518ba18ababmr66426pfv.76.1653292181512; Mon, 23 May 2022 00:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653292181; cv=none; d=google.com; s=arc-20160816; b=IJ3O4b42jKRsMy6M+AdUqWlyXnz7NtDHS22AAXjYj7dSoFMe5ywYfIXG0U/n8nMmql F8heX9G8BZZ4w7hAzcEWL26vdYxveWp2OE5CIkGM15vSDPZzCHXJIqNQC/5upg7nuymL ircasuFpm5yTZqmXpL6ztCf1xcdjOGEc36qu0UNC6E5kUvJQWpnGJXyvmJrdJoX6Dp1t W84GALnaUlCJXE+jE4IPaNBGkEcTlSTLqAb0WumI0JKqbAfeSWAq79vMGFOxLBSuYrPj dQ9cWaA6Clhx0IgjfHHrFcVoRIZDahXOo5eAFcCavwUSXyaz12+76k5so0FyuANiE1Q6 pnCw== 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=jvzZl/M0O1YlALpmVIHr8zQIgrImM1sB6aaC27zq2bg=; b=KrvchS+utERIK75a9UYHFpUCjYDI2tg0LIgXYbLuEWjOGgEQQfazJqg/atmgBkbOKB CPfFdibO6eX1cYgpyvZLApdvLmG16WGK5OMTE4fmBidG2/71sNnXm93biUHenKoyHZHo qkr/Bf9x8gBhXic1hhNsy3Lodl3t0Fp+9Y8NC/s9of0vxm0GPWew12KowJV3SZaQQILp Le9F9CRC/cR6qtvIaMCUqiHaEX3ZX6XklqKgzUkRTUkSPfLFXCAb7GpMbAHrDp4k8nRr DJsei2yGdcZTIXAmuGydOA2uwMOtTH9JsJze7mjTK6fmcBYTgDD6PE7a22BEqKNffpUX Rgvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dLksq0kC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id j72-20020a638b4b000000b003c1eb460705si8957000pge.33.2022.05.23.00.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:49:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dLksq0kC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 035F920F4DB; Sun, 22 May 2022 23:53:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350134AbiEUHYK (ORCPT + 99 others); Sat, 21 May 2022 03:24:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbiEUHYG (ORCPT ); Sat, 21 May 2022 03:24:06 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AD16CA91; Sat, 21 May 2022 00:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653117845; x=1684653845; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3asQqEgN3HAp03iRISKotmL8Hzh0H0AiQ5h1mdRd4mU=; b=dLksq0kCgeneLrIg7mul/8YOhdwXbgG9ejzHDLGiuwwVna9ncgzrQHy8 TIIQ9NkKNcOrPrF6micVC7/5SYVFusSyXtp0Dg20naCsBZO0IVK13Ior6 LmquI+TSuqbZ7tgtSmTW16VilI3HIR80O0c9NoWwy6lD4yN8UmjdRtAZ3 T9jjBkcII9EHxpqtP+waM2Gk2jEaFi0aeqtOmBMRGmwbo1/vtXuHGJMNK iJiiZfq5yI1TPWlwlD5p8VIBSNFji2kMmuS6nhS3iknP5iSBGdshu4dpI 1oe9HtE8jNTDANiTYA4vy465tIXLt9ElHiN2znHVy0Ni2eJTXL/hjn2Zk g==; X-IronPort-AV: E=McAfee;i="6400,9594,10353"; a="254871996" X-IronPort-AV: E=Sophos;i="5.91,240,1647327600"; d="scan'208";a="254871996" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2022 00:24:04 -0700 X-IronPort-AV: E=Sophos;i="5.91,240,1647327600"; d="scan'208";a="599658223" Received: from tower.bj.intel.com ([10.238.157.62]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2022 00:24:01 -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 v2] KVM: x86: Fix the intel_pt PMI handling wrongly considered from guest Date: Sat, 21 May 2022 15:23:18 +0800 Message-Id: <20220521072318.1226928-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.5 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. 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..378036c1cf94 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 (!kvm_handling_nmi_from_guest(vcpu)) return 0; kvm_make_request(KVM_REQ_PMI, vcpu); -- 2.32.0