Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3480235rdg; Tue, 17 Oct 2023 17:02:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFeI1dSFJH/kQ4mfTnmg6Zr5B3RTLThUeiZPQ5XILb5YrRjwDoKkMvpktwKhfjZYV4a+1b5 X-Received: by 2002:a05:6a20:7492:b0:158:1387:6a95 with SMTP id p18-20020a056a20749200b0015813876a95mr3794817pzd.19.1697587345563; Tue, 17 Oct 2023 17:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697587345; cv=none; d=google.com; s=arc-20160816; b=Eu2C6qb+d0vBmLTFnwm7UN1zKaDVySqOP5fzzNASXtacfvE8gnQMhngLvzZK8ef4L0 6dltMhYlKAAvPiAy0VuMMk8+9EwxdFExonekn/ATJzzcTFWrrBzXdDnJmIr+GT6jAONO 25jWnw58SXZr1VnlMnBrmN9EjmiilfKQfNfmWheoofIIq3skDqglY/iD2A6ivHzVb+wR l2Zjk3UiswX8W1L3ZMIRNBp/cxJoQ0spEH5JYDxqeQStOsvNvIKT3Fu0a5p/iz8cN8oA kZ+gNL68f+RsjQDxWUqIWf60Wb0W4ZlnOciEgwLGxVR2w2QI67GWexJ/xgLfbeWGjWN2 7J9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=E/603XVHKaUaM8lugP87JFe8YYdPyptNnYZAmeymCgY=; fh=Rz09qwPU1WnoCUu7xJUwmet3YKHK9B3cmNE0QUUfKvg=; b=WYpRJ3M72Pb1NljSc6uhRS120nFBjS3a7jvzks5WY8t5v4AIkLmb+bwE1YfSYVpYBA PyVitnw1wwVTzwFYc2hVTpD+BdI1CLu48kIbiQNEIoL8nJrjjhbuhMYyfu9rCgZvmlnL ZulLDtKdey/IGtyrHkhDTWK+5/cOQwO9f9XdrqFsriSjxXzc177HkNA5v9dsCl8/oZ64 MlaZboZY3bKXg3oWoVZrPglS+n7m8MZ556aW8saSWj21Hu0Biss1n8zvGzDpwIz7PQ1o 97sDnSXpgAqZY371o/yG6GppoSETvZUTQX3tf0s2hgZaIhEFUQG1QTzqALrR9C8X5AB1 QzGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=majv7qat; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b30-20020a63931e000000b005aa0e024d62si881211pge.102.2023.10.17.17.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 17:02:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=majv7qat; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CB29B807B99A; Tue, 17 Oct 2023 17:02:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344148AbjJRACE (ORCPT + 99 others); Tue, 17 Oct 2023 20:02:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233700AbjJRACD (ORCPT ); Tue, 17 Oct 2023 20:02:03 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5FB5C4 for ; Tue, 17 Oct 2023 17:02:01 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id 6a1803df08f44-66d122f6294so40893356d6.0 for ; Tue, 17 Oct 2023 17:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697587321; x=1698192121; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=E/603XVHKaUaM8lugP87JFe8YYdPyptNnYZAmeymCgY=; b=majv7qatmKp5hGEMBDnrcA/xbS7deDukIQnOFM9dOmjfsR5yTtI/fh9vZqOeE6a3+I zHB0ptmqwmSjHEjaNF1bHyj76vG+mHkTb8CzzmS0CLSl8vW/xrdR+oeYtV3NDPbkhJuk eY9HfyzB3w8lKw22JBZALwsrMiVe0RQZ25wlVz4MruYuL0n9R6oiiqsUYSUo5sKCw35h hkSl5piDBIhaw1Ol1kWt61AdwUpalXYQUf66tmKAKa3PGAYdYe7bffojY0/2XCFfYaaJ Ek0QEgKSijvvlu0E+gHtOBCONzYD26k37W0AaIfIwtP6iBUMeUJ5wd2jCo/8vqNTA2LB Tx9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697587321; x=1698192121; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E/603XVHKaUaM8lugP87JFe8YYdPyptNnYZAmeymCgY=; b=Jv7DWe5ZpsKz+EYhN5yB9XnFZ9Bs3ByG1ot3XnKgfhOPSdgd+XGz1Yo3yNfX1bNl/a vi2jmYoARtfOsBt29bmFNDHhrzalJSePRjX+E9BSnkNu59i6LXhki/xvbi9H/2MFgZjn TujYmgMNQ38vcKHeaEMEPzP9s7ybymzbv/m03QCbDLevyOeLaQAhk2tp46auaYAJrsak C0ap2UmahLflI1J5Zj0jlqfV3I5fBclMYQ+utDfeG/DsVLXnDEM173/as1+VT5DH8ivr il0HbIIYXRLKoyrzGnm4JADP569aldCBcOY2i5R2OyksE9MjFN4LuYDs2JjMOUJgWcBG uGsg== X-Gm-Message-State: AOJu0YxV1wn1qpkkUJ7CGHzNkiIIucZb1I0b3jw7ZEv6F7WbxOcpgr3J xVVw6NFkotcwVOKIttlrGc16wD7cZBoScPca8V6LYQ== X-Received: by 2002:a05:6214:2aa1:b0:66d:3c8b:5f44 with SMTP id js1-20020a0562142aa100b0066d3c8b5f44mr4336406qvb.27.1697587320791; Tue, 17 Oct 2023 17:02:00 -0700 (PDT) MIME-Version: 1.0 References: <20231002204017.GB27267@noisy.programming.kicks-ass.net> <20231003081616.GE27267@noisy.programming.kicks-ass.net> <20231004112152.GA5947@noisy.programming.kicks-ass.net> <03b7da03-78a1-95b1-3969-634b5c9a5a56@amd.com> <20231011141535.GF6307@noisy.programming.kicks-ass.net> In-Reply-To: From: Mingwei Zhang Date: Tue, 17 Oct 2023 17:01:23 -0700 Message-ID: Subject: Re: [Patch v4 07/13] perf/x86: Add constraint for guest perf metrics event To: Manali Shukla Cc: Peter Zijlstra , Sean Christopherson , Ingo Molnar , Dapeng Mi , Paolo Bonzini , Arnaldo Carvalho de Melo , Kan Liang , Like Xu , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhang Xiong , Lv Zhiyuan , Yang Weijiang , Dapeng Mi , David Dunn , Thomas Gleixner , Jim Mattson , Like Xu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 17 Oct 2023 17:02:23 -0700 (PDT) On Tue, Oct 17, 2023 at 9:58=E2=80=AFAM Mingwei Zhang = wrote: > > On Tue, Oct 17, 2023 at 3:24=E2=80=AFAM Manali Shukla wrote: > > > > On 10/11/2023 7:45 PM, Peter Zijlstra wrote: > > > On Mon, Oct 09, 2023 at 10:33:41PM +0530, Manali Shukla wrote: > > >> Hi all, > > >> > > >> I would like to add following things to the discussion just for the = awareness of > > >> everyone. > > >> > > >> Fully virtualized PMC support is coming to an upcoming AMD SoC and w= e are > > >> working on prototyping it. > > >> > > >> As part of virtualized PMC design, the PERF_CTL registers are define= d as Swap > > >> type C: guest PMC states are loaded at VMRUN automatically but host = PMC states > > >> are not saved by hardware. > > > > > > Per the previous discussion, doing this while host has active counter= s > > > that do not have ::exclude_guest=3D1 is invalid and must result in an > > > error. > > > > > > > Yeah, exclude_guest should be enforced on host, while host has active P= MC > > counters and VPMC is enabled. > > > > > Also, I'm assuming it is all optional, a host can still profile a gue= st > > > if all is configured just so? > > > > > > > Correct, host should be able to profile guest, if VPMC is not enabled. > > > > >> If hypervisor is using the performance counters, it > > >> is hypervisor's responsibility to save PERF_CTL registers to host sa= ve area > > >> prior to VMRUN and restore them after VMEXIT. > > > > > > Does VMEXIT clear global_ctrl at least? > > > > > > > global_ctrl will be initialized to reset value(0x3F) during VMEXIT. Sim= ilarly, > > all the perf_ctl and perf_ctr are initialized to reset values(0) at VME= XIT. > > Are these guest values (automatically) saved in the guest area of VMCB > on VMEXIT? > Never mind on this one. So, if both values are in Type C, then they should be saved to the guest area of VMCB on VMEXIT (according to APM vol 2 Table B-3). So, this means KVM does not need to intercept these MSRs on pass-through implementation. Thanks. -Mingwei -Mingwei