Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp849277rdg; Wed, 11 Oct 2023 07:16:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERbVRXarY2uBWkImaSjjC2W7ceGrae3m/TyZMwncO8wKqHjdUcZr9+0yJ8YkqWgMhsA1dr X-Received: by 2002:a05:6a20:7292:b0:14d:f41c:435a with SMTP id o18-20020a056a20729200b0014df41c435amr24729507pzk.39.1697033788974; Wed, 11 Oct 2023 07:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697033788; cv=none; d=google.com; s=arc-20160816; b=f2QyAz7y0YVSn2Yu2oolstWpPz7wWgLGVwTs0QllcKTcIeA8bAkia79z5heMucvwf0 Er+mig3wPJu+m5Fv4pezJfocP8mhrj2tf0MOgo+mwZvgQuQ5nygLlOXuW5BcYUMbsQ4E tI8QFmkvjyx/T/oFEBCdlEK9e8yAAfu+6BJ7vLMORQ2xzINVqOaY+bol0VVw0GFuqQVa TPiLtvpsKKOIOj5NXVZwwk6W5z9StcoPFd/+WLYO+Qjfi7LTh0aVsrIvXwnjVkRKeWQR dGk9NQ8h11Tv7PSsRCV381EJXNfNhi3L+GbtXkiaPJGFbRbmteSEfZs7OfyARDOhwS8+ cqfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=h1+bFrTxC9bNpWggJ1/WhAB0lCHgMj17Prrv9vHF3zw=; fh=9zFWJbMWB1X6uAbIgs3wnsybd2Vx6vKgge7xb/YAUtU=; b=FwQQqtuh9qofKTN2X/gwdsUbp/MzvV/iMU+cz9aV1QIBiv8vjzBzG9jmKfJxa474OD PiZv/Eu869TPQvaLjFGAOULN/1fb0TSlYY1qQWsBqJ2hVViZqbUa+nyLr2QJEXPcGg/o gWiEC9LnOqZ+sNNEeO9zrz7u0bQ/9mNIazJWmB1qWJzzr8WNR4Kps5y59X4RYjlDK+06 EaUa3wusCuDkkKjjGucJbrD4Ls/wqZRWHXy+1SEJPaCGxWV8dGPZvKxfiW6MTNy8bmch HcqaW+VYYDMZRDcecIiv37WVYBZfT3zntt0uwrMUR6VBcneyljdoFlIjKW/gdybSBKtP d8kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=LimFqPKT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ix14-20020a170902f80e00b001baff05d890si13854819plb.313.2023.10.11.07.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=LimFqPKT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4A4B28083DEC; Wed, 11 Oct 2023 07:16:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234952AbjJKOQP (ORCPT + 99 others); Wed, 11 Oct 2023 10:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234870AbjJKOQK (ORCPT ); Wed, 11 Oct 2023 10:16:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6938CB8; Wed, 11 Oct 2023 07:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=h1+bFrTxC9bNpWggJ1/WhAB0lCHgMj17Prrv9vHF3zw=; b=LimFqPKToomKM3ZLamW+/KIPGe FZJLYLU9SZ+I2Tz2YZPKHuBPxyLjsKL/1NrfjN7vtdtt6npXZY64RrPjJR0gGZFjoe6FvTNdHqY0J U/bYopgTCcQ647n9v/bFwel9DWixgUjZvcXP6R6z142PzIYuyKZWQGSxb/FOT/r6TxmoCvCmohxnD se/4tkB5jrGq0Kz9zCrnxkwsEJ87orN6fOdF1aXJxIbb14gjlMxOLHtpNsb8w9hbTWeFPPlL0JlXR ICf4vHeuJRR4Te/5/xgvZP1ZY5QTH8Z8S34GNYkntSo3FXBIJXT546pquCKZlPa7j8hTXhyMjS0A5 Bwd3W/oQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qqZzr-00BCga-NG; Wed, 11 Oct 2023 14:15:35 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 64E5D30036C; Wed, 11 Oct 2023 16:15:35 +0200 (CEST) Date: Wed, 11 Oct 2023 16:15:35 +0200 From: Peter Zijlstra To: Manali Shukla Cc: 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 , Mingwei Zhang , Jim Mattson , Like Xu Subject: Re: [Patch v4 07/13] perf/x86: Add constraint for guest perf metrics event Message-ID: <20231011141535.GF6307@noisy.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <03b7da03-78a1-95b1-3969-634b5c9a5a56@amd.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 11 Oct 2023 07:16:25 -0700 (PDT) X-Spam-Level: ** 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 we are > working on prototyping it. > > As part of virtualized PMC design, the PERF_CTL registers are defined 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 counters that do not have ::exclude_guest=1 is invalid and must result in an error. Also, I'm assuming it is all optional, a host can still profile a guest if all is configured just so? > If hypervisor is using the performance counters, it > is hypervisor's responsibility to save PERF_CTL registers to host save area > prior to VMRUN and restore them after VMEXIT. Does VMEXIT clear global_ctrl at least? > In order to tackle PMC overflow > interrupts in guest itself, NMI virtualization or AVIC can be used, so that > interrupt on PMC overflow in guest will not leak to host. Can you please clarify -- AMD has this history with very dodgy PMI boundaries. See the whole amd_pmu_adjust_nmi_window() crud. Even the PMUv2 update didn't fix that nonsense. How is any virt stuff supposed to fix this? If the hardware is late delivering PMI, what guarantees a guest PMI does not land in host context and vice-versa? How does NMI virtualization (what even is that) or AVIC (I'm assuming that's a virtual interrupt controller) help? Please make very sure, with your hardware team, that PMI must not be delivered after clearing global_ctrl (preferably) or at the very least, there exists a sequence of operations that provides a hard barrier to order PMI.