Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp942880lqc; Fri, 8 Mar 2024 17:36:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIhsMyfZj6TNxqKyIt1YoLJu9lW6VKNUVMzZ7Lm9TGiHWmgLxhrSmLCzzyTqrP+8GfzalJ4jRQ9QohCUj+LNJcRd/27BVdv6XWl0zckQ== X-Google-Smtp-Source: AGHT+IGErjCLwNCRXmj6BKn7tC3KkYIhs1CyGexoti4Hjtcv+eHY9g6HYNiZgqQ7lpOcWhbi7q0X X-Received: by 2002:a17:906:a116:b0:a45:ae85:6413 with SMTP id t22-20020a170906a11600b00a45ae856413mr200674ejy.44.1709948217960; Fri, 08 Mar 2024 17:36:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709948217; cv=pass; d=google.com; s=arc-20160816; b=pRb/zmk1T+HI7JuF2/ZYZpQ+aSYGGaRFoH2/8l2AzuOnZ7PeVrPzgJCVn3lJUylKac 5sUGwobwgrhvyKjvOYN9Sp8Fqyryc1QMgYj59adPILcGHYY9FYFUNZQa3dlCtD16xGZ2 P6/2UmQdk2PR6bn+SmQzvPOQOzr+y+qbaigk2J7EexZURmPQElKmcko0vQXKrX65IVWU w+QRcNMEjj+lT+CKxmoMgb1moCW6zPqXsAs1xD5lsFDyPAWNuWa45ukhkcAsWrhGBW4I hgrbdSC2X/vE8vOAHVqxYuzAlQtDnVWsIyRaqzOojRSMgbPFdeoqOZff2ssljskRnBNO lDpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:reply-to:dkim-signature; bh=bZoHkUtSLo4x8GP9qkez26jA5e/nyhOVKeVVLDBsGLg=; fh=EzcAUdFX46G3oJmHU6WpAEdofG4DEjQi/NwG/PTG+do=; b=c5DogiryAItQHrDSHhAHjazsUY1le6WySHnfC3EX6M+xH8o1wnoS5dVnE2t0JPIW/t 0w1TNTj6EktBIXJTXWaMfog2ux8fWlfXZD7M3qJpSRKY3WEtOouq/lDSvbeaCyGUt2qb x1BpuFc/mHvZDqT7Gd3WvfSZwvl4F0LOF59qJxCC6eroXgW/g6991gLp+qVrdVQGyQs3 /lWnmdSomsob09V+6NJCRXdTiTuuK1xN4P8FqUvM/99r7OAi2wvpK8HbEZDoTQe0xEh0 2OIwbp9bcGU6Br/D448GZnd+8zsNwgI1GwwCmfTxyg/ariXSu9qGSAeqx0QsmNlcaFFm emtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=X6U0MnFs; 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-97737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97737-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e26-20020a17090681da00b00a3e7b498e1asi304307ejx.728.2024.03.08.17.36.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 17:36:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=X6U0MnFs; 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-97737-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97737-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 ADB3E1F21F47 for ; Sat, 9 Mar 2024 01:36:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75C55171AA; Sat, 9 Mar 2024 01:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="X6U0MnFs" Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 5AB15185E for ; Sat, 9 Mar 2024 01:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709948205; cv=none; b=ZMy5fy1MTMDlm+ygBfCBlcB1hi92jczMpUHHIUBeCuVyI2fyCQ3aPEdlK3XjqLLNlYeJsw9uGyp87DA360AaP1Xl2Samcrkww+k+XGCHCAdKQneCdYP1y26dmvS6x/igDTKHOuSBB/ZXB2yvK9XGH4vlPpSRBZmKtGlWegneLd0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709948205; c=relaxed/simple; bh=KNAhwOBL8cw8T6ZXppejn/QBiDWrlTqw/s/Csa4uJDM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=fvLd5AeQNzJpZ49P0WPddPvRFeuKNrRfwEvkVRxVVeBPJd/wa0ejhScInMaTUaK0WDuBWIidsLuoqc6RJdcTnS2DLSME/GOMAJdclTMjjvDL81/cUBL2wTkPNdINzM4WTVfF5yExTIuL5SYQ6WAyciSOZFmPpsvul9rTZW6GAeY= 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=X6U0MnFs; arc=none smtp.client-ip=209.85.210.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-pf1-f202.google.com with SMTP id d2e1a72fcca58-6e673910497so550178b3a.0 for ; Fri, 08 Mar 2024 17:36:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709948204; x=1710553004; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=bZoHkUtSLo4x8GP9qkez26jA5e/nyhOVKeVVLDBsGLg=; b=X6U0MnFs8be3Ny6CTWgAFNDnYe1pHGmbSbgNO35iJBkgn6+INrAQ+sV5hNC5xvv0kn uznpg3T4TCGmTbsroBxnglj753clltYUclxpNh3HzsF7n64uMTAz7IDnGLpfiCb0IqBe qdaNbRVSjNsSOYoM5nGW/wq0iCzJBD+wKYctAgcuKMO/DPr6IRyukyjZhVIVGX5Chp8Q sthisM39MylnC/d+gmzaTA7TdCv8K0wsKutwXS5Nr4fYSwJFQNYQN06E+NWGpMexj+Vh po8P2Tm77I85P/Typ04YM3PwmPNHNwuscSh8NiM4tXktel+hmZkDJ4DldK+8cFKJJ05y 8shg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709948204; x=1710553004; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bZoHkUtSLo4x8GP9qkez26jA5e/nyhOVKeVVLDBsGLg=; b=Z7LEAm2dEsV787rV64Q+NUDhagWNI5aABvLPHtKiTYoLRmdKlUnJ6bXqBnHr22+rfa GSosWPuWuukKzsK/6x8pF3wwgrj7BaLqblcehbxA5/vtQZoeosppdpmvBDwCNXxbgnU5 zCGAcdF0Dk2NxC0ZxOB/21S/TEdsKuTr2dkurWq1djizronvZoQt6dwdn1r+Y9WFvs2y sv/o1Znnj+3T4MbKSi0OszbKoQSgBeOTElx9q/SYkrzviXoFIeArMtmKWxM5SFz5xY0o HQI8KA3kSqmN7aCn/cz0Z1Rw4YC+m9Imnb15CMNMbN8tMwsDlhDt3L0mNwlScyb0kCxI Zzug== X-Forwarded-Encrypted: i=1; AJvYcCUwolGe+GdN0s/wMLPE4iFLTfaxHuQ11/YrkvC4YICx6854G7WniTVnLNF5FYjy6AcOdWaZ2bei/xt3beIn+cBNwfpugHzrI0lgiAuP X-Gm-Message-State: AOJu0YxPwXe5wA2yX7cOxCBdCdXMNOcmUuLrJ/PNEzOyLKZ2sikV7SRc 9s5q027NndMEvdXJ/OTlpgIoJ4MySg0MAaDhgKJQkzIXqV7yFTOpCYtMf715xZ+4N35o4RpI70/ FWQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:c95:b0:6e6:6dd5:7a40 with SMTP id a21-20020a056a000c9500b006e66dd57a40mr53380pfv.0.1709948203703; Fri, 08 Mar 2024 17:36:43 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 8 Mar 2024 17:36:39 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240309013641.1413400-1-seanjc@google.com> Subject: [PATCH 0/2] KVM: x86/pmu: Globally enable GP counters at "RESET" From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Babu Moger , Sandipan Das , Like Xu , Mingwei Zhang , Dapeng Mi Content-Type: text/plain; charset="UTF-8" Globally enable GP counters in PERF_GLOBAL_CTRL when refreshing a vCPU's PMU to emulate the architecturally defined post-RESET behavior of the MSR. Extend pmu_counters_test.c to verify the behavior. Note, this is slightly different than what I "posted" before: it keeps PERF_GLOBAL_CTRL '0' if there are no counters. That's technically not what the SDM dictates, but I went with the common sense route of interpreting the SDM to mean "globally enable all GP counters". I figured it was much more likely that the SDM writers didn't think about virtual CPUs that can have a PMU without any GP counters, versus Intel really wanting to set _all_ bits in PERF_GLOBAL_CTRL :-) Sean Christopherson (2): KVM: x86/pmu: Set enable bits for GP counters in PERF_GLOBAL_CTRL at "RESET" KVM: selftests: Verify post-RESET value of PERF_GLOBAL_CTRL in PMCs test arch/x86/kvm/pmu.c | 16 +++++++++++++-- .../selftests/kvm/x86_64/pmu_counters_test.c | 20 ++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) base-commit: 964d0c614c7f71917305a5afdca9178fe8231434 -- 2.44.0.278.ge034bb2e1d-goog