Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1622052rbb; Mon, 26 Feb 2024 16:11:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqsXXFAgIQiYHceP3Nc+U//d/8UY2XkrKFn4YEbvHPErU8AOInTFySzGK0SDiulxXtvplGNTy0ZPiTGdry1qzsow2qtZ0er+K+kgXxxA== X-Google-Smtp-Source: AGHT+IHxuxvIZOxMtG1L6s62Zl1vflKfFdbdgFXdSlRmSDKPOIYkR4m1PhPRYnFGr7lsbnZOpF4g X-Received: by 2002:a17:906:c445:b0:a43:af0b:ec4a with SMTP id ck5-20020a170906c44500b00a43af0bec4amr88629ejb.28.1708992680830; Mon, 26 Feb 2024 16:11:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708992680; cv=pass; d=google.com; s=arc-20160816; b=tPrCHrxZYMFbFQaM3WsgtQA7pvBQuCG8puAVurGd457DZxRYpfPU7wAykKJjqAoRNT jQ0DOgcsZskq3sead9V7Gb7S++xRLtGVJNKkr0VfKgRE42SGk+v2r30YT1NkZw79+Dsi Ewi2WfXA5aresmBePt33xCec46ylWbQyMBh4dfvLl/Ew7dE89e9zAgcuDpvBFVRPdcBO 5ltECX+C/wMsd4133iLvsesgJzGpIi53PnrBpNA3HDQhN9oZYt18FvgIZ31DBjZJxvqA CrSmqIhZ3a+dMgb5j37MR2ttso8YFxnG8d/livIkr3EpXe/QmOyXGQYbXJ8N7wl7LQGs Sgfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=6lCojt3BigDKF1Z6DNZEhqVi/bp1on2H69YUvcRX6rE=; fh=vgFwJRc5aDQiS4MWbsKwy7GHdxfaDT2hSxdam2AJKmE=; b=Lr/jfHSbnSXy3l9agoYcu4v5p66MdfT1nNefSSrRdNGBqhfXTE+eu17bOz5O7H/ji/ fHv9duE4tnzDD/L2Z6ejrW6k7RIgQc1PxgJz9G7/q0S4KDXN8HFLV4f38VA6+ccqif9s lvxR1r5yUyfjSTAQ0TMEO1QkX9dEIKoX0FsfcmttnAqXY22XCBg66RIDXZZKLV999WdO 5ILE9suzKLl35suSLZXPAxVhaFbkb/bm0YGpWbSWF3Wvyu1ZaOdc/zsoPKLy9OsTl1DK /SjAWR8VKfYwxHzw4DWGU9/wRxECspmSEN6AoQSL9YmvKWY6y+nKVnh4KpJQKZmScB3r HvAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iVg84o3j; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-82460-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82460-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gz3-20020a170906f2c300b00a3e6eeecbfcsi192125ejb.867.2024.02.26.16.11.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:11:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82460-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iVg84o3j; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-82460-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82460-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4B9661F22F6A for ; Tue, 27 Feb 2024 00:11:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCB44A23; Tue, 27 Feb 2024 00:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iVg84o3j" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2F4360 for ; Tue, 27 Feb 2024 00:11:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708992669; cv=none; b=dYLz50dpJJaQZPCIXke9yjFbnn3iKAKTseLNMwQ07m2/+Eo3K6aFze9oAUW4FK9gFnwNiDOl/QaF2n8fiLIwWdr/lPuz3cWuHaI1enHeJnMpDbJELuqyx9p6PbArTtyJn3TuePu/WRWZl6KGVd4+86pW9SqeGDS90nUBgP8qQNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708992669; c=relaxed/simple; bh=+0HW0I+Sds5Zs5b5rGWRfw72kX6o58U/vNE4sJhB39k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=II0Sz4GYtHOZXulDehE496Guw8SoPlxLl00xb0xANuVyfLG64wnP4/u5u33HeiOasxuzsHIq56TVkiedeYe/prYujuni9TJRXlKdfRrXzwhTPxazuLSuv1qdgndtBmViUVF0IS0W3CsbIpMkSF+FwpH5CFOdBNHUFE2yhU2N/Rk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iVg84o3j; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b26845cdso5036847276.3 for ; Mon, 26 Feb 2024 16:11:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708992666; x=1709597466; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6lCojt3BigDKF1Z6DNZEhqVi/bp1on2H69YUvcRX6rE=; b=iVg84o3jTA0sEICa/8a1TjsEsQEmnmlEwwSm0wl3jpljNZnXCOQ/7GkoBDoXg30YJX mZDb/bl6MksxgKfY4fn5jYCeWTKULA/2NhfcXOMpO0DfuZt14UxVwuDU7aduEIzCdlw1 VtL430VDUWxKgpCOr6i+E1VqLoCZj1ORloQb/v6hAV4ooeDHcJkI7ZgNAMzw62EBYFWK ylb+C2gNLo2LJOOj0fGihCJSxUKASSZeiSTTk1Aro5DDW87EkT3dK4rFNUNqSSFSGHJX CReumaOy727tnXbMpBSgu+NjX/ajHV6K7/WRGmeaH78DTFfv2P8e1uteFIQrSnPAyFR9 8rDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708992666; x=1709597466; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6lCojt3BigDKF1Z6DNZEhqVi/bp1on2H69YUvcRX6rE=; b=Q6DjS/u8sWfv/GjqCqr2Nj6vpE6ALwaTN1utzH0C4lWIAAd4khUsycd+gyefmnWTJk kDFDfAUZTj+zyFYh3Sv/7Px9kfKIOGkYW3i1F2OCPHO4gojisRq7iNi+uz9Fv9iQeA/l M7p61UlSDXCjdgsIv9CruyHmTFRkz+3e44Yo0NUxpE0g5W1B3n43l6uAz95IgBRZ6xNI jSSpZCeuuu6ilap2pR0yPi/To+eC7it4P+V+6EY8MyDryZ0MdLtOBb+c213Fc56fPF/a nhg5QN9HtwQJkdEiTGBq39eD0xheeTMZaFKfnoCC/8z36BOuirgn6c1K3RjDhNt3+Y5h ZMGQ== X-Forwarded-Encrypted: i=1; AJvYcCUk4gCdaQ8yC6AZXyyN9et1PsWtKmCUim7Ts9Bbu7xOYnCF4BGPIgSpRxFxfcPJ2Wx8fars1Cvh5cL8+cfpIqNu146ymg/jd08dYIkR X-Gm-Message-State: AOJu0Yzd/m88T6ATv1HiTdiJmvkmqxivad7g1BXpH87lZ3U0ru1y3DBf rm1x1MhmT73pmBXTxs+43dAoovTkjTuNrYZp6NiZgtyfMeG8jGeQ4KViLxY0uA0k+zhU/0JcBWH Hxw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:83ce:0:b0:dc6:519b:5425 with SMTP id v14-20020a2583ce000000b00dc6519b5425mr200134ybm.11.1708992666356; Mon, 26 Feb 2024 16:11:06 -0800 (PST) Date: Mon, 26 Feb 2024 16:11:04 -0800 In-Reply-To: <585a36d2-6e46-44a0-8224-8d4cd54d0dd3@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231206032054.55070-1-likexu@tencent.com> <585a36d2-6e46-44a0-8224-8d4cd54d0dd3@gmail.com> Message-ID: Subject: Re: [PATCH v2] KVM: x86/intr: Explicitly check NMI from guest to eliminate false positives From: Sean Christopherson To: Like Xu Cc: Paolo Bonzini , Andi Kleen , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Sun, Feb 18, 2024, Like Xu wrote: > On 7/2/2024 5:08 am, Sean Christopherson wrote: > > On Tue, Feb 06, 2024, Sean Christopherson wrote: > > Never mind, this causes KUT's pmu_pebs test to fail: > > > > FAIL: Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x2): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x4): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1f000008): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: GP counter 0 (0xfffffffffffe): No OVF irq, none PEBS records. > > FAIL: Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1): GP counter 0 (0xfffffffffffe): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x2): GP counter 0 (0xfffffffffffe): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x2): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x4): GP counter 0 (0xfffffffffffe): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x4): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1f000008): GP counter 0 (0xfffffffffffe): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1f000008): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x2): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x4): Multiple (0x700000055): No OVF irq, none PEBS records. > > FAIL: Adaptive (0x1f000008): Multiple (0x700000055): No OVF irq, none PEBS records. > > > > It might be a test bug, but I have neither the time nor the inclination to > > investigate. > > For PEBS ovf case, we have "in_nmi() = 0x100000" from the core kernel and > the following diff fixes the issue: > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 995760ba072f..dcf665251fce 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1891,7 +1891,7 @@ enum kvm_intr_type { > /* Enable perf NMI and timer modes to work, and minimise false positives. */ > #define kvm_arch_pmi_in_guest(vcpu) \ > ((vcpu) && (vcpu)->arch.handling_intr_from_guest && \ > - (in_nmi() == ((vcpu)->arch.handling_intr_from_guest == KVM_HANDLING_NMI))) > + (!!in_nmi() == ((vcpu)->arch.handling_intr_from_guest == KVM_HANDLING_NMI))) > > void __init kvm_mmu_x86_module_init(void); > int kvm_mmu_vendor_module_init(void); > > , does it help (tests passed on ICX) ? Yes, that resolves the issues I was seeing. I'll get this applied with the above squashed. I'll also see if the tip tree folks would be open to converting the in_{nmi,hardirq,...}() macros to functions that return bools (or at least casting to bools in the macros). I can't see any reason for in_nmi() to effectively return an int since it's just a wrapper to nmi_count(), and this seems like a disaster waiting to happen. > > If you want any chance of your patches going anywhere but my trash folder, you > > need to change your upstream workflow to actually run tests. I would give most > > people the benefit of the doubt, e.g. assume they didn't have the requisite > > hardware, or didn't realize which tests would be relevant/important. But this > > is a recurring problem, and you have been warned, multiple times. > > Sorry, my CI resources are diverted to other downstream projects. > But there's no doubt it's my fault and this behavior will be corrected. Thank you.