Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp586655rwr; Thu, 20 Apr 2023 03:50:43 -0700 (PDT) X-Google-Smtp-Source: AKy350YJbP6A2GctgkD3v7p105kDs560S/xdx/TZIkOsaTjMhpUHB8ary1EfQBkcOSHAdkXjYxGW X-Received: by 2002:a05:6a00:851:b0:637:920c:25fd with SMTP id q17-20020a056a00085100b00637920c25fdmr977225pfk.17.1681987842709; Thu, 20 Apr 2023 03:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681987842; cv=none; d=google.com; s=arc-20160816; b=mVayFhGMu3xx8yeT0Wy2ydYcCUFDTZvk3+ARpYd+y8yGwuZh70cPY8u1A+Fq6EM4ta 57IDsSm66zUDV5rSAR0uko0QZRIskBgCTTZjdGwMUuzYkcQ21ENbl5xwi9bECe7o8FyP lVrNu3RtOuq8B1TAAf/p9x9SSQnQczyuq15G1/aKUmY5mb0Z9tCNYMKhg+tRX7KMRARD l6lvdwJGboW13lC7of4k0MulKh77uldCq7xjIDJJZCGgApcdnS8+kuvXsuRlS7VkLRah 1g/MES7qK3btZzgU57aYEpvoDWr/CD7ZDRot1vXnbGbXhyE5yedIDxyuyErc0OaEViJm 5jWQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ucz1xYqm1NnRhQqZf/NHWVK0FuNxfx3TblIgxh14nj0=; b=K8tQnewE+cqpKgvn5uqIwAyXvdSj0JGSraFWoXPUWiVewPYr7qIHWbIyUkE16HtEC6 hCT8A0B8bnRc3OADTSnwgJOTjakb9x+eBduSerN241fKkr1CjqRz7avhYsXIb/ObDDc0 GGrR5ctsxgveenLQQ16TKCf1MlbtS6FdHIph2sNpcpKzAj22ZUiYhF2/Ns1IdX6ZgrUe QcUXP67vIr9HNs9XwfTZ3Lsj4qk1mNc0xrDpCw8ePeatFxqNdxsAzQtrH5S/YbWN079I 1Ula7R6FsaagyeuwdUk1p45JBcD3qpccKvqrGmuNY4QdYDQZCkJm8YdiGT2QM9Dr5ELX tFCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=YU1yuqWA; 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 t14-20020aa7946e000000b0063b895e9781si1428412pfq.138.2023.04.20.03.50.27; Thu, 20 Apr 2023 03:50:42 -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=YU1yuqWA; 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 S234708AbjDTKtB (ORCPT + 99 others); Thu, 20 Apr 2023 06:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234755AbjDTKsM (ORCPT ); Thu, 20 Apr 2023 06:48:12 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08714173F; Thu, 20 Apr 2023 03:46:47 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-1a66e7a52d3so7924165ad.0; Thu, 20 Apr 2023 03:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681987606; x=1684579606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ucz1xYqm1NnRhQqZf/NHWVK0FuNxfx3TblIgxh14nj0=; b=YU1yuqWA1beCHR+/WoSpYyEhAgWVxMb3wPQqqrz+yDablssc0FlgD8jlB9iRqhjjSz eiUAcJfII0DeQtv5RMY1o2HjRVYg+AS+biIXN9g7l0vXlMAbaFYHHU9WFo/UEe1EK8LR 0b+Uor6WXmLF7wbhAo3GDayQxBkFxI0FzyBsaf+IPD4HficYFf2Og0q9kxUVIgDd/HTp AyCHu68qt8kAgGqjHpwfmZoFr70/d4sPcQXMhqNzSHucLAHmaZRo9ISvMnbRwXa9Tixy 7Xa1HUDDk1u6MiaU33c15KppS/1rVcx+zzRInDlKpgz5lsIIlGNvXObVhhTcTztcQjPa DW8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681987606; x=1684579606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ucz1xYqm1NnRhQqZf/NHWVK0FuNxfx3TblIgxh14nj0=; b=JbWpSugKTu5kBiO09vtJmmUdQDK4mJH2Xx2vFvBqeJm+80P+0YRleVtj0ougJYti10 R6vF+6z+qG1VMxwQXpwMqu4piaZWnjZCA5FPhkAv8V2zw4rdU1nK+q6BMkLwM8amoEUy ur7wdeh1VwHNM4dnToCwjNL5jVu7tArbjucuP9ICG7ILNwwiBkaleA+N/BiDaf3L9upP T3EXnXZU2HjZwjALIOOjE7CcoNJa62qjSg5loAvPMTl06OBSVchbbNapGkgvsvWYQiAA 7z9B2w1ke4p8JlsORvyFLHmXqrLA3qzgTuNKongeAtT9oyUXeQcyFhKE01uwY+L2XA7a BfvA== X-Gm-Message-State: AAQBX9cVPyh43LO4BjeSxW2iVyYFvwDZMdh4PalwCj8GfwhF0BnwFAXW 9gugyW5RxSIFYkllS3YJBc4= X-Received: by 2002:a17:903:246:b0:19f:3b86:4715 with SMTP id j6-20020a170903024600b0019f3b864715mr1206887plh.8.1681987606197; Thu, 20 Apr 2023 03:46:46 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id ju18-20020a170903429200b001a526805b86sm923735plb.191.2023.04.20.03.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 03:46:45 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Like Xu , Paolo Bonzini , Jonathan Corbet , Shuah Khan , Aaron Lewis , David Matlack , Vishal Annapurve , Wanpeng Li , Bagas Sanjaya , Jinrong Liang , linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] KVM: x86/pmu: Add documentation for fixed ctr on PMU filter Date: Thu, 20 Apr 2023 18:46:19 +0800 Message-Id: <20230420104622.12504-5-ljrcore@126.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230420104622.12504-1-ljrcore@126.com> References: <20230420104622.12504-1-ljrcore@126.com> 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 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 --- Documentation/virt/kvm/api.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index a69e91088d76..b5836767e0e7 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -5122,6 +5122,27 @@ 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; + +Note once this API interface is called, the default zero value of the field +"fixed_counter_bitmap" will implicitly affect all fixed counters, even if it's +expected to be used only to control the events on generic counters. + +In addition, pre-defined performance events on the fixed counters already have +event_select and unit_mask values defined, which means userspace can also +control fixed counters by configuring "action"+ "events" fields. + +When there is a contradiction between these two polices, the fixed performance +counter will only follow the rule of the pseudo-code above. + 4.121 KVM_PPC_SVM_OFF --------------------- -- 2.31.1