Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp490786rwd; Wed, 31 May 2023 00:56:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6LYx8lLVsk5hfcL8nTspFbHu2+jr/rwuzYFpQju10UOvXAecF0GPK6kZbumjAQJWHF9Cwd X-Received: by 2002:a17:903:41cc:b0:1b0:4772:d344 with SMTP id u12-20020a17090341cc00b001b04772d344mr5896123ple.57.1685519768566; Wed, 31 May 2023 00:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685519768; cv=none; d=google.com; s=arc-20160816; b=QZ/pL4CLaC34l7y40pooERjNiqG24ySRbl4xwOXZFA5ObCqbihzAOZqt99Qo7WlQql y0EF1CIixcgEXRf8V3r1WFidSWQ+KZqr5QqbpSnbKUp20ZAxg9rxrNX11XJszmk4ZZKa 2DnKZNYbFbN82ZJy27Ez4j8Kr/cVbk3FnlrAd7hDuXUJ7BLV56+pXz4Z0rm42rpxPaWW aSOTDhgHC/hmHnKXYwE2SPu/5M/diqs1b2zNYu4IukJrReXg3TJ9XO1Q/n9GfOozhQmr Ib5RaoZKWYH+FXNHd/eqFQsd2wmOSl+5r/z0dT+Ex8e/achXOhTs/kvqlJ8gNmNedfhh t87g== 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=gdwwVTrlhtX+5DSC9fXBJMoGfz6wjbsQlSprVqEeSn8=; b=sC58MhEvxhfRHs6vx1P7N0iITDuGjqaxWvGyB/UJUiEOdmJAazUhDl3wFkjQaTaKoK +caDlSzSf1GW/QExD7M5NQiP+E1UWDsRGRTQzMcBxlTA0fG9E0BzbymvjKUEzMcTH7Pn SqEen+sJDtxcxRM2/nYorrxn91N1Jgrlm94yWnJdYwmgIREgW3JiKcXpAt89nfV7SFau nqgCJKETvW6LoqEGEjzsJzm+Yz/i8gedGzIuowtGA/E0IeePben+gpMp/kAAzR9Z63cw 5sc/cc+ySc9BgyyPcoQyN4Wn0UFbFXKhq5mlPNMAkiV0sabQh0h38p39s7uJRp4unhnj MxoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=sabBT9LS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a170902ce8400b001a27afc07d9si504092plg.146.2023.05.31.00.55.46; Wed, 31 May 2023 00:56:08 -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=@gmail.com header.s=20221208 header.b=sabBT9LS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234815AbjEaHxH (ORCPT + 99 others); Wed, 31 May 2023 03:53:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbjEaHwY (ORCPT ); Wed, 31 May 2023 03:52:24 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A8C125; Wed, 31 May 2023 00:51:13 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id d2e1a72fcca58-64d2467d640so6255620b3a.1; Wed, 31 May 2023 00:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685519468; x=1688111468; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gdwwVTrlhtX+5DSC9fXBJMoGfz6wjbsQlSprVqEeSn8=; b=sabBT9LSb+JP8+jmnubHp4wKdxjz44rRuVMYu17NCTV8v5bVTf17iIFVlBd68Cms/+ OA9YufLPvxMaxousG1Cxl0pPy1ni66HrNMqawkwYpW6Ji6NERoIZR9EBbsRYLE48iEQM rEtG9pNqcFC6e5MWWMUfg2hhgMEdmHhu1KKbROV0gX6ChI3rr3gSmbWvpPlXZreep6Rr o+gYbKDAryciO/Ksamc3UJg7VdwgoAoUV9QEZjeXBinSjeC7RJQsCGZTQac99bhZ1CYL 5GPtt9522aXo20R08cjxyikQwe4Nb6O94x7fVMXgbsL8jgjPPi7sz0s2BjOR4WggmBpN ernw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685519468; x=1688111468; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gdwwVTrlhtX+5DSC9fXBJMoGfz6wjbsQlSprVqEeSn8=; b=epktWWQ1nTbVcKVrSl46ri0X5rEWvx3k4Z+s3Swa6XIUWrYspN6++IQQt2gSKvTmag VBKnPSYcveSlWrQ3a+HTR7LXLxy9GFVgcQnjTF0Uwz3iVQE7SSEJneP/LrCPXgFYTBaK LtBr4RX0DINb+psYp7vWpHvOqXgdCfcp4X2TIeX0q7OpfkpRHIK3Hlrh0DGOw2yNSH4y 3PQqP753aU8dtly9vHKbaPf3tqwdfuWoO7d8GTD/wdNVz7hQTMp1/dcFewwzo0VZP1vb ezU+6rjPzj68wbpRNAWZ2XHkKmDRGzxcB3bcmZV09RsueeDbxDvmt+QZ92UNHS9n4rKS v7XQ== X-Gm-Message-State: AC+VfDzs6MrXj2tNk3+XXcllLaGHtugrUpj9f+6186j5ponMGwmzd4x8 55WXsTG12rMQoZXl+vsHt30= X-Received: by 2002:a05:6a20:12c4:b0:10f:1f0:9b43 with SMTP id v4-20020a056a2012c400b0010f01f09b43mr5941801pzg.6.1685519467721; Wed, 31 May 2023 00:51:07 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id i9-20020aa79089000000b0064f95bc04d3sm2797803pfa.20.2023.05.31.00.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 00:51:07 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Paolo Bonzini , Like Xu , Bagas Sanjaya , Wanpeng Li , Jinrong Liang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] KVM: x86/pmu: Add documentation for fixed ctr on PMU filter Date: Wed, 31 May 2023 15:50:52 +0800 Message-Id: <20230531075052.43239-1-cloudliang@tencent.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Jinrong Liang Update the documentation for the KVM_SET_PMU_EVENT_FILTER ioctl to include a detailed description of how fixed performance events are handled in the pmu filter. The action and fixed_counter_bitmap members of the pmu filter to determine whether fixed performance events can be programmed by the guest. This information is helpful for correctly configuring the fixed_counter_bitmap and action fields to filter fixed performance events. Suggested-by: Like Xu Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202304150850.rx4UDDsB-lkp@intel.com Signed-off-by: Jinrong Liang --- v3: - Rebased to 5c291b93e5d6(tag: kvm-x86-next-2023.04.26) - Revise documentation to enhance user understanding. (Sean) - Post this patch separately from the selftests changes. (Sean) v2: - Wrap the code from the documentation in a block of code; (Bagas Sanjaya) v1: https://lore.kernel.org/kvm/20230414110056.19665-5-cloudliang@tencent.com Documentation/virt/kvm/api.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index a69e91088d76..9f680eb89b2b 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -5122,6 +5122,24 @@ Valid values for 'action':: #define KVM_PMU_EVENT_ALLOW 0 #define KVM_PMU_EVENT_DENY 1 +Via this API, KVM userspace can also control the behavior of the VM's fixed +counters (if any) by configuring the "action" and "fixed_counter_bitmap" fields. + +Specifically, KVM follows the following pseudo-code when determining whether to +allow the guest FixCtr[i] to count its pre-defined fixed event:: + + FixCtr[i]_is_allowed = (action == ALLOW) && (bitmap & BIT(i)) || + (action == DENY) && !(bitmap & BIT(i)); + FixCtr[i]_is_denied = !FixCtr[i]_is_allowed; + +KVM always consumes fixed_counter_bitmap, it's userspace's responsibility to +ensure fixed_counter_bitmap is set correctly, e.g. if userspace wants to define +a filter that only affects general purpose counters. + +Note, the "events" field also applies to fixed counters' hardcoded event_select +and unit_mask values. "fixed_counter_bitmap" has higher priority than "events" +if there is a contradiction between the two. + 4.121 KVM_PPC_SVM_OFF --------------------- base-commit: 5c291b93e5d665380dbecc6944973583f9565ee5 -- 2.31.1