Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4357472ybl; Mon, 3 Feb 2020 17:27:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwI5+l5aPoPMEENk6+KKKIW+VVTDiOIcd9wEaQQ36DxQPDZ6TkyDtMPcgZmEpZQr8IejMBY X-Received: by 2002:a9d:7851:: with SMTP id c17mr20595716otm.58.1580779652298; Mon, 03 Feb 2020 17:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580779652; cv=none; d=google.com; s=arc-20160816; b=EKorBt6bNe8rrUfdnfBhDT7g0JrfqHC7CBpZBaFB2Uv4BMXC5XIpgAeSwGpyhug9Ks s6kFv9DAOOQ7DhXMl33WI27D9S/7BnPesKDETEgWTRH/tp1oXjurvA7W7gPxcOPWufVu DStlPacRDzAiztpTQGsg4bCCjOQBiZwmDiJe9uzOiH4/7L+gzfHw0gLrdfDH/nx70bKv 6arQ0wqc9FqJZD18OQGHtyccZau6fKFyWPNhiA1el4qE8pkunCjuzekHszwIK+X+igW7 7xNaYeqakQHX2o+Bdq4aZWl7kLZ0kla2ATwa4tNW2xRPervfRnL5X4genOTtR7reGsQJ 8PKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=QUGZT2MVbSZ5vv9JAqfeam9eYCtpwd6NYyrPTQGL4Vw=; b=BWdDyChr+aFjJUtluOrYWfAZffTmRxbCC8ZuGUDz4KWrDjnebmkHDFNa/qxFYdqBzz zMz4wKo1wMFzkZ9pZYs9RE02C6jCzNRdIeMMAEQTe8LghNwImKoIoJZE4WU/GS9JSyAd La4TTRjnNn/d7Ze+FHkPjxoBzQA2aR2dBzGlgcIEjJmCn44okV0tjBTlX5bwBH+7s29f RlHjW8r1gCbl5gS0Qci/WCL7TvGehB4iRAvgV+mrihwiZY9e+AWORliZFG7BCvi6EtZh zcoeL9ooDbUgBTcqFWFW3KsS7DET2oobe0RYerfwYPnKWhUWlHYVpXoM3V3ZktejXPVJ XqDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LMaPXvTV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h138si9107227oib.6.2020.02.03.17.27.20; Mon, 03 Feb 2020 17:27:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LMaPXvTV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727112AbgBDBZK (ORCPT + 99 others); Mon, 3 Feb 2020 20:25:10 -0500 Received: from mail-pj1-f73.google.com ([209.85.216.73]:42653 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726924AbgBDBZJ (ORCPT ); Mon, 3 Feb 2020 20:25:09 -0500 Received: by mail-pj1-f73.google.com with SMTP id hi12so839657pjb.7 for ; Mon, 03 Feb 2020 17:25:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=QUGZT2MVbSZ5vv9JAqfeam9eYCtpwd6NYyrPTQGL4Vw=; b=LMaPXvTVHWRjR4OY/kwNL2KfAHa8UpJCbQ0fB/vH0vTkR8weS3+o9HmWUvxODuRA4v 9eGAqaftuBVncplz+Wug33AL9+V/WCN7uk+FPQfHd5+A1AsXHSPQlSeQaweYV0uSixD2 +R7y90zPyGDs/57TAHOvUZrRDaToG9qNnQvZcYcBx92QXf7LzAJPBkrN8fwwAWzqO8xR z2+Fz4CR8lpoCEsdkzQo+V70TvTVhNfa5MSC3MpGeLYmhY9RxuxWO7+JNbPLoS67HTNK OLQ4bDNxSF/Zyg0ujWp5pA9GN9o3W70W9mJr4rJmiqr3bu4xFkH4ZeZl4YSzsyVQymwL IFJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=QUGZT2MVbSZ5vv9JAqfeam9eYCtpwd6NYyrPTQGL4Vw=; b=VwUPI1VjGOdzrRnkndu8cv8x2tQwc6TdAf5lEakcgvsFwTqmHYdKXsGWleTLEK1ljC 0HTQ9/CcZmR1u/3IDrMr94XLzSplgjIDRVdn22B0UYl+eAynTt/qW2SSlqvQsRwbciKn OON1DUIKqsMFf0ez1cuERePoGgCujp4dnIvHABdd6guX9JoTBR1Fcgt8KFgwYozIP0A/ qYhPf+jQ8hbuGYtOc8TTIZAVDHOpTV2O912gdk1BJ2dbWZ1xC+a9wDIbeyG/jAl56cpl 9+LF2dg1QYHF2g3N7AJDoGs5IEJkdl+L2tQRLq55IM4xA1nrH7usC0DyET93gQeOlLM+ 61dQ== X-Gm-Message-State: APjAAAWULwN0e/8PsofURn9NQpqFWB9FoY16PwlD46ZwkMYwAcoXGUHE LgQeJpLnXhFL8EndOTycZ5hugcY8lcUu6hk= X-Received: by 2002:a63:cd04:: with SMTP id i4mr20017956pgg.281.1580779508971; Mon, 03 Feb 2020 17:25:08 -0800 (PST) Date: Mon, 3 Feb 2020 17:25:04 -0800 Message-Id: <20200204012504.9590-1-ehankland@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter From: Eric Hankland To: Paolo Bonzini , Jim Mattson , Peter Shier Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Eric Hankland Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ensure that the value of the counter was successfully set to 0 after writing it while the counter was running. Signed-off-by: Eric Hankland --- x86/pmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/x86/pmu.c b/x86/pmu.c index cb8c9e3..8a77993 100644 --- a/x86/pmu.c +++ b/x86/pmu.c @@ -419,6 +419,21 @@ static void check_rdpmc(void) report_prefix_pop(); } +static void check_running_counter_wrmsr(void) +{ + pmu_counter_t evt = { + .ctr = MSR_IA32_PERFCTR0, + .config = EVNTSEL_OS | EVNTSEL_USR | gp_events[1].unit_sel, + .count = 0, + }; + + start_event(&evt); + loop(); + wrmsr(MSR_IA32_PERFCTR0, 0); + stop_event(&evt); + report("running counter wrmsr", evt.count < gp_events[1].min); +} + int main(int ac, char **av) { struct cpuid id = cpuid(10); @@ -453,6 +468,7 @@ int main(int ac, char **av) check_counters_many(); check_counter_overflow(); check_gp_counter_cmask(); + check_running_counter_wrmsr(); return report_summary(); }