Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2156184pxb; Wed, 9 Feb 2022 12:04:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAqQWXC909J/My0vopiJZMOXY10FVYJ4ahKaMF0sk15AN9cXIrNKULWii5LgXfpP23jJ9F X-Received: by 2002:a17:90a:4b8d:: with SMTP id i13mr5230289pjh.152.1644437051421; Wed, 09 Feb 2022 12:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644437051; cv=none; d=google.com; s=arc-20160816; b=FwygJvr0yd6wCMxmF+895pic7rON7Prs0Q6/1BrsG/41/grmaLrreHVWzmFlnxmdo/ SQ6AfVZPqRppUfeJsM+CqediL2/RYSC8XWQn5Fge2aQwiRgKC0804aAB9sWLshXguOv1 dTBdcMV0dqADvpjv1MFutQYaIiPBEdRi1KuJqi/VnFhnM7Ep1WN7SPKJOfzA3kxYhFfO W3iPf96WK0gb3yDiRRW9Y0aDV3yRcysm2Jm3QlKf7+3fZpP0LkH4Py2ktiTh3IUTvMCZ D9ObH7tVCrqzFwUU08KGZn7vDhOUkLIYMJjNPl6Rtz/vH3B+F7BFkjsnjchnDwMf8OQK 9VKw== 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=k7inhu8PhMJK6yGxgiDvgZaOGdJa0rrk9ukESAEO+Jo=; b=yJHnuquZuDmV0bOPYZxBkCrsut1EdxtU/zarUudDelZyHrGru56MqzMEYc0l41VdGG mEx2bXIPXmfIHPAEWcZUysZf3NMp+85fsUQ6+Ke5wIwRm31OekWXdeoy3BtJR//v3cPk xjrPXYXuh7TEnDyS9tfhzBl4L+ln5C2BarzowSRazHmwdkOmBCsMhIx5kQNEWu1WS3ZA kjU/ERwlAQ3AsOn5xSakBG+5lrmXWwPVAdniwTDK4DtaeE7JNPgz1CCG9X0E8Fli75NW Y51kPF5fBszJs6PAMKh5gbQuEVZHAtXqI9ucy1AFCGxyXhbespEp2ChzGgU7XpUsRl4t gFIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=oMBnkAtb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b23si11291375pls.362.2022.02.09.12.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 12:04:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=oMBnkAtb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 536E9E05116C; Wed, 9 Feb 2022 11:52:12 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241034AbiBISw1 (ORCPT + 99 others); Wed, 9 Feb 2022 13:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241343AbiBISu7 (ORCPT ); Wed, 9 Feb 2022 13:50:59 -0500 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0114C050CCB for ; Wed, 9 Feb 2022 10:47:39 -0800 (PST) Received: by mail-ot1-x32e.google.com with SMTP id o9-20020a9d7189000000b0059ee49b4f0fso2175767otj.2 for ; Wed, 09 Feb 2022 10:47:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=k7inhu8PhMJK6yGxgiDvgZaOGdJa0rrk9ukESAEO+Jo=; b=oMBnkAtbT2pyt87Qd+fh7ucVAOoZ03oqSs3/0kWtRhsWcb/tRHhTPKH2SMhVaiz4EC nhpkIVwjaOl6FfTH/GasB2aGxssA6hfaiuHLEUkr4HckBGvY8Ipd2XYKEu8AKm/rWLVM XCEJqZi4Ex/VQkRDsJCrJxP4vjp5UKrVTSxD+DRvRiwDuAgtfDA72GtJKVIfolZEkoaV iWqFXkB+oBNa/El48FhJCRBdLvHrLaRMI8Jt1H4HYasV+oGfyRRArMg+UUK3tzw/UVwK lYPOWzIXFkGJiRBMwcc4ZQeXJyJhVIhR4PvIVv9TDKwjqKF1P9qHHB/llsE0ZNV52pA7 KXVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=k7inhu8PhMJK6yGxgiDvgZaOGdJa0rrk9ukESAEO+Jo=; b=GWpc8BAajYfgXBQI10dGn/jNUMAii0nUJR44UED/RQSjZDsJPbdjhF9hx13MVZPw1R CqznUvzfA8i/4DX3gqpYGDBSeC2olYKRphY8wqdO5cd5HkwzrsVZDj4TytMkgv8dl8VP T8qym+gmjglRqmesCRWESmNp5XkeCRYKedaqNAhzBWMo5NR55Fji1uU/J8VKLYrM2YNZ 4LEzehhAfHj4I+1zUK7D6dpT8xICeWf6S6jzmgDH0N0Y9VVgp76OT1y+/ldW75QDWZQU pNNbjxgV1PK7HUWgp6J/NLIhVdwTDEq36pfzmByNXA4G8tQMTocrBqIU93MCDGmMm8Y9 SVHw== X-Gm-Message-State: AOAM533VDXyrluMsMJsTQcWDQwvKt3DNxEnrIury9JLSWUiGbmzZEIcr rvP4ZoFSZAwhi5+MgrdJAmC6cLjWrdg27kRdmNsdcw== X-Received: by 2002:a9d:4e03:: with SMTP id p3mr1530696otf.299.1644432458616; Wed, 09 Feb 2022 10:47:38 -0800 (PST) MIME-Version: 1.0 References: <20220117085307.93030-1-likexu@tencent.com> <20220117085307.93030-3-likexu@tencent.com> <20220202144308.GB20638@worktop.programming.kicks-ass.net> <69c0fc41-a5bd-fea9-43f6-4724368baf66@intel.com> In-Reply-To: <69c0fc41-a5bd-fea9-43f6-4724368baf66@intel.com> From: Jim Mattson Date: Wed, 9 Feb 2022 10:47:27 -0800 Message-ID: Subject: Re: [PATCH kvm/queue v2 2/3] perf: x86/core: Add interface to query perfmon_event_map[] directly To: Dave Hansen Cc: Peter Zijlstra , Like Xu , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu , Stephane Eranian , David Dunn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 Wed, Feb 9, 2022 at 7:41 AM Dave Hansen wrote: > > On 2/9/22 05:21, Peter Zijlstra wrote: > > On Wed, Feb 02, 2022 at 02:35:45PM -0800, Jim Mattson wrote: > >> 3) TDX is going to pull the rug out from under us anyway. When the TDX > >> module usurps control of the PMU, any active host counters are going > >> to stop counting. We are going to need a way of telling the host perf > >> subsystem what's happening, or other host perf clients are going to > >> get bogus data. > > That's not acceptible behaviour. I'm all for unilaterally killing any > > guest that does this. > > I'm not sure where the "bogus data" comes or to what that refers > specifically. But, the host does have some level of control: I was referring to gaps in the collection of data that the host perf subsystem doesn't know about if ATTRIBUTES.PERFMON is set for a TDX guest. This can potentially be a problem if someone is trying to measure events per unit of time. > > The host VMM controls whether a guest TD can use the performance > > monitoring ISA using the TD=E2=80=99s ATTRIBUTES.PERFMON bit... > > So, worst-case, we don't need to threaten to kill guests. The host can > just deny access in the first place. > > I'm not too picky about what the PMU does, but the TDX behavior didn't > seem *that* onerous to me. The gory details are all in "On-TD > Performance Monitoring" here: > > > https://www.intel.com/content/dam/develop/external/us/en/documents/tdx-= module-1.0-public-spec-v0.931.pdf > > My read on it is that TDX host _can_ cede the PMU to TDX guests if it > wants. I assume the context-switching model Jim mentioned is along the > lines of what TDX is already doing on host<->guest transitions. Right. If ATTRIBUTES.PERFMON is set, then "perfmon state is context-switched by the Intel TDX module across TD entry and exit transitions." Furthermore, the VMM has no access to guest perfmon state. If you're saying that setting this bit is unacceptable, then perhaps the TDX folks need to redesign their in-guest PMU support.