Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp26202993rwd; Mon, 3 Jul 2023 06:48:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlHBSHJooy4X+prul+pvvSR3e1DKkrEC4GlUJavFzxo+glzUEc3FsRJ0zGJ8kNM+pJ0VVPBo X-Received: by 2002:a17:90a:1cc:b0:263:987d:b5b9 with SMTP id 12-20020a17090a01cc00b00263987db5b9mr6102502pjd.15.1688392106797; Mon, 03 Jul 2023 06:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688392106; cv=none; d=google.com; s=arc-20160816; b=iXGs+XVByKbYugwEfGeGkt6KSLEFIFqbqrC7jMqidR/Pur/oRBk725349nz5vLxLR7 XmWeSzSwiWauXgFMOK0i095brjGcNPga7+v0iLaTqIU2UHYY4DRhdJDAMIklLcNKdv8j 1a3kLUnrx5sRjDdMNhN/CF6JlbXcMSRH7dvHwrLuT/XG8iENGQfQyKwAvkJhm83AjO2H O261kabcnLff6oZEAGvKAzodWFhosX9GzrMcXVv2nPXrAWLw16TP4GAHO4foEPDCZun5 LR1LPPy/sJiBMPJ1FBbSooUVuta8mwZJlqdQdivVm7HtckP47NB4+8l4yaVCoBH3diOi aVIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=MZnqhy/csMNXbugFtNWNDpN2XhhdE1oePTXoQDzZgeU=; fh=peT54FrC4qKHdCE+rrk6gg49+AEzUcDZpO05/oPYj3o=; b=PtqfxiYDstC6jIO/qEZygOvE3QTVJmddGT8mF4gTU0xMZvq/MLheOBKVwSGo8DE6UC 5KbsRp1fgwzgxGwOvlwI3iAEESIzeKcrnfcaG54hbdzql7ghoqLB+//yzTW4Jjlxu45/ bKCA/CfNVFsnHqDtiCDW7nFJik+y7x3laSixEV1nAPkOHkyOJEINhjc/gAHw2lGCmlmj U3pMnX9Zd0T2jSXMnUEKG6guDrqf24RkYHiYnzrW70tBVX5tj7Ld2mZYS4rSBhVouFRB RpVX/0Xw0B6Rpg6eXTGP7S0cW/CrbUXTL/BPF+jiZs/Q3EvIlYKg5lj/bPGIJJa+q3rg ff3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=j8+tx2eM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nv5-20020a17090b1b4500b002634977e6e7si1617720pjb.102.2023.07.03.06.48.11; Mon, 03 Jul 2023 06:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=j8+tx2eM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231501AbjGCNeA (ORCPT + 99 others); Mon, 3 Jul 2023 09:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjGCNd7 (ORCPT ); Mon, 3 Jul 2023 09:33:59 -0400 Received: from smtp-fw-9106.amazon.com (smtp-fw-9106.amazon.com [207.171.188.206]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21B1CE3; Mon, 3 Jul 2023 06:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1688391234; x=1719927234; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=MZnqhy/csMNXbugFtNWNDpN2XhhdE1oePTXoQDzZgeU=; b=j8+tx2eMFLT0PgwFTtZQw0kVMx7+H3or39OowaVAvarHLB94Ff9it+IS duh+gLFsqCyy7aOa1ZVQHI6hreQPGkwd6Zrj323xnraG3MfdOEr/cX9C4 v4t3EFDFN/0tqyJGreFuxthm2ekcMxamrxM+w+yaoQsqVXxyCnYnABsdg c=; X-IronPort-AV: E=Sophos;i="6.01,178,1684800000"; d="scan'208";a="657678907" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-m6i4x-94edd59b.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-9106.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 13:33:49 +0000 Received: from EX19D010EUA004.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2c-m6i4x-94edd59b.us-west-2.amazon.com (Postfix) with ESMTPS id 226AA40D4B; Mon, 3 Jul 2023 13:33:47 +0000 (UTC) Received: from EX19D033EUC004.ant.amazon.com (10.252.61.133) by EX19D010EUA004.ant.amazon.com (10.252.50.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 3 Jul 2023 13:33:40 +0000 Received: from u40bc5e070a0153.ant.amazon.com (10.1.212.14) by EX19D033EUC004.ant.amazon.com (10.252.61.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 3 Jul 2023 13:33:35 +0000 Date: Mon, 3 Jul 2023 15:33:29 +0200 From: Roman Kagan To: Sean Christopherson CC: Jim Mattson , Paolo Bonzini , Eric Hankland , , Dave Hansen , Like Xu , , Thomas Gleixner , , "H. Peter Anvin" , "Borislav Petkov" , Ingo Molnar , Mingwei Zhang Subject: Re: [PATCH] KVM: x86: vPMU: truncate counter value to allowed width Message-ID: Mail-Followup-To: Roman Kagan , Sean Christopherson , Jim Mattson , Paolo Bonzini , Eric Hankland , kvm@vger.kernel.org, Dave Hansen , Like Xu , x86@kernel.org, Thomas Gleixner , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Borislav Petkov , Ingo Molnar , Mingwei Zhang References: <20230504120042.785651-1-rkagan@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [10.1.212.14] X-ClientProxiedBy: EX19D031UWA004.ant.amazon.com (10.13.139.19) To EX19D033EUC004.ant.amazon.com (10.252.61.133) X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, T_SPF_TEMPERROR autolearn=ham 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 On Fri, Jun 30, 2023 at 08:45:04AM -0700, Sean Christopherson wrote: > On Fri, Jun 30, 2023, Roman Kagan wrote: > > On Fri, Jun 30, 2023 at 07:28:29AM -0700, Sean Christopherson wrote: > > > On Fri, Jun 30, 2023, Roman Kagan wrote: > > > > On Thu, Jun 29, 2023 at 05:11:06PM -0700, Sean Christopherson wrote: > > > > > @@ -74,6 +74,14 @@ static inline u64 pmc_read_counter(struct kvm_pmc *pmc) > > > > > return counter & pmc_bitmask(pmc); > > > > > } > > > > > > > > > > +static inline void pmc_write_counter(struct kvm_pmc *pmc, u64 val) > > > > > +{ > > > > > + if (pmc->perf_event && !pmc->is_paused) > > > > > + perf_event_set_count(pmc->perf_event, val); > > > > > + > > > > > + pmc->counter = val; > > > > > > > > Doesn't this still have the original problem of storing wider value than > > > > allowed? > > > > > > Yes, this was just to fix the counter offset weirdness. My plan is to apply your > > > patch on top. Sorry for not making that clear. > > > > Ah, got it, thanks! > > > > Also I'm now chasing a problem that we occasionally see > > > > [3939579.462832] Uhhuh. NMI received for unknown reason 30 on CPU 43. > > [3939579.462836] Do you have a strange power saving mode enabled? > > [3939579.462836] Dazed and confused, but trying to continue > > > > in the guests when perf is used. These messages disappear when > > 9cd803d496e7 ("KVM: x86: Update vPMCs when retiring instructions") is > > reverted. I haven't yet figured out where exactly the culprit is. > > Can you reverting de0f619564f4 ("KVM: x86/pmu: Defer counter emulated overflow > via pmc->prev_counter")? I suspect the problem is the prev_counter mess. We observe the problem on a branch that predates this commit Thanks, Roman. Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879