Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp961617rwl; Fri, 7 Apr 2023 08:00:02 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0y8eXNlmdZmCkNqgrZ5jMXof4+noeJ8EPmLrbKGxVVP6lBJ+al2Nr3hXYwqRuQlgjrKsP X-Received: by 2002:a17:906:d979:b0:935:535:42a7 with SMTP id rp25-20020a170906d97900b00935053542a7mr2592207ejb.51.1680879601737; Fri, 07 Apr 2023 08:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680879601; cv=none; d=google.com; s=arc-20160816; b=zZZn9VCG8SSQcgGvD99kFFxWyl5ktm7vR1EaYC7zzfCQKELqHw1qicfN/OQqhgiKdH ky3jRrKpAtYB+yOlAi0talCJZc19o7x+12ugvIZM9b+O1zim/roIS2yLIotYBxDgLStv 1DHTnLJwmU+dksflL75hKxbLXi57yj9Sfn01FUwqiw/rw6ySbaZcXj75iLosGKRtsaSL sK0Jhnw/KCTO9h43KCegK62ld1rFoyeIK0KSCq8rERzlHZV9Xjr3TrLZP6GWqZwGC2sh kW4a/f/hWAlanZpu70FPksFYE6EqBLaZsABqr0I9fzv+/fkBeUMKpVAtZJ2fn07Wy/xM zEDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=+6mWqAen+huGMPyP+21svtQ1LsJRWj8zxdxP8oalBOY=; b=GsrfTa77KnUw+waOyCuJS+5kkL8kQYu0Cv8MqRT/QX5saP/Ssplo5pHFOaZU7dijRp 56TYVi3LOwrvRvbHVoTbDFNvhm5g5oMg0cYevmglf8dVfNIhARRO6GRiZCYyXnl2ZHy3 w8xE15x1PcH9t3K3zGQUTjiQ+Ug5sK6y/gM50QM8Qs1gBUAOaeoOQhHMUwFyUzSnT1vf hmzmSaV7vg61drijAAfiFZABAQ0QZoKtCkUKho1bjHXikctGpVPRCNRTyzl9FAPXPkSS 0dg7Zh6nuXwl1wEM8y7nAQt831344s+81min1ehjtXrTleCZm4OQGqpHTyLMqURDnFHH ajSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Qlq75cZ7; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qo7-20020a170907212700b0093b5bf364c1si1750438ejb.987.2023.04.07.07.59.34; Fri, 07 Apr 2023 08:00:01 -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=@google.com header.s=20210112 header.b=Qlq75cZ7; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbjDGO4S (ORCPT + 99 others); Fri, 7 Apr 2023 10:56:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbjDGO4R (ORCPT ); Fri, 7 Apr 2023 10:56:17 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35FEEA5CE for ; Fri, 7 Apr 2023 07:56:16 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1a1990341f9so645765ad.1 for ; Fri, 07 Apr 2023 07:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680879375; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+6mWqAen+huGMPyP+21svtQ1LsJRWj8zxdxP8oalBOY=; b=Qlq75cZ7kqIeRwjCavq0ViVRfhkzlCIXzjxa9eZBBBjynshERxB99MwysnxeC58UyE gNdwwdEhKGB6vPlTn/+vxrsLGAI7Q4bW/wWNiSV8CqqZqF+luN6dyz7PmOGbsX7k6FKM H4ZNdfags4nGzxsv3pOov5H72JW8mM/rK8WqPQ/JaIETVk3Ws7HfinFWyNsQaIGSx7yX TiBRqDzqHE750SFx1w/FcRGxv+LbvwwJIQ8Y0qcJ64z+hLvTFNf5bqbmceFZF8eWbPQP IhLSM4YWViEULGPX4B/tgQ7txptQO9M8p8Vnyq0Rr6LvhzZLiRUjA1zgOt5ieEMXZwjz 4sRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680879375; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+6mWqAen+huGMPyP+21svtQ1LsJRWj8zxdxP8oalBOY=; b=zGcl0oZ02yaXZvW6UytdOn65oT7hz/wdzMQa6XpEcmE1nsjKRmoBRjY7mDvM2iNoCu IpYdDwFMB4aY/RiGMIAiWTQi0fHgQir2L4imLC0Bdl4mWaAAu4Ptrqq0SpOGLgROQD4u Rt8tM1TuZy//AiVYEvg4FWMUcu+e5sDNUW+ojtp1RgP8sDU8OK4l4PwOay4tQTB5ne2e gGpKQweRvinILUydlMfeSpoGOUaUCCBV779OZOIghtHFzBv67Vs5qUTYcWv0IANwZat6 glgOrp5TJ19APnQKJZ7t1qPA8faSferqTxZfWsYKeZI6azQfQcNXBMZbaFl1UpQagXHs thlQ== X-Gm-Message-State: AAQBX9ddicEvXEwdUGZN7yg2kLSzBtKAjV953Q+D68kXgPsusmJwds/S xUOddayPHb056zMYA2hgJKjNFqZ/+rI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:802:b0:627:e180:abed with SMTP id m2-20020a056a00080200b00627e180abedmr1498433pfk.1.1680879375751; Fri, 07 Apr 2023 07:56:15 -0700 (PDT) Date: Fri, 7 Apr 2023 07:56:14 -0700 In-Reply-To: <509b697f-4e60-94e5-f785-95f7f0a14006@gmail.com> Mime-Version: 1.0 References: <20230310105346.12302-1-likexu@tencent.com> <20230310105346.12302-6-likexu@tencent.com> <509b697f-4e60-94e5-f785-95f7f0a14006@gmail.com> Message-ID: Subject: Re: [PATCH 5/5] KVM: x86/pmu: Hide guest counter updates from the VMRUN instruction From: Sean Christopherson To: Like Xu Cc: Paolo Bonzini , Ravi Bangoria , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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, Apr 07, 2023, Like Xu wrote: > On 7/4/2023 10:18 am, Sean Christopherson wrote: > > Wait, really? VMRUN is counted if and only if it enters to a CPL0 guest? Can > > someone from AMD confirm this? I was going to say we should just treat this as > > "normal" behavior, but counting CPL0 but not CPL>0 is definitely quirky. > > VMRUN is only counted on a CPL0-target (branch) instruction counter. Yes or no question: if KVM does VMRUN and a PMC is programmed to count _all_ taken branches, will the PMC count VMRUN as a branch if guest CPL>0 according to the VMCB? > This issue makes a guest CPL0-target instruction counter inexplicably > increase, as if it would have been under-counted before the virtualization > instructions were counted. Heh, it's very much explicable, it's just not desirable, and you and I would argue that it's also incorrect. AMD folks, are there plans to document this as an erratum? I agree with Like that counting VMRUN as a taken branch in guest context is a CPU bug, even if the behavior is known/expected.