Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp517068rwe; Fri, 26 Aug 2022 09:05:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR64PszY/7TG6VAREKG5bto7PP0qBSdjiL7q6lpLqth1nHZgpwGA+agQSUgYBHFWehWZX9pD X-Received: by 2002:a63:2323:0:b0:42b:15da:5ada with SMTP id j35-20020a632323000000b0042b15da5adamr3649136pgj.423.1661529958870; Fri, 26 Aug 2022 09:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661529958; cv=none; d=google.com; s=arc-20160816; b=au7w1ZFLATTjRdhuU2pshbJGc4xzDX5RVS+0yY8PZCwqeWnEK4FF4dZK1UXV7Xbpkd AGhQwED/pYbHjij7DC88269ZFl5gSPUIIEsvgs66HNg6MEI93idDg0eWdmX+qR9kSvD2 KJtVgnuFoP0Eg8t1XeYE5nXrMoSVQCgadzqhrNE6BFnslgzPv0tob+P8qqag7fXZtXZ6 DzpIRYVNfcs/Fojvj2fUV8HDwS21p0eQBT519i8vQREhjaBL9ghUJJS5k8B4/KM8S0jK eZYJbeesgipvdesicajZWrGUciphX/df/BR7iXoOsUg97irJRJzKyNRfD/4q4ArJ8ZBB R68Q== 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=rDCiGRameoc44J7lHWbl0JPQBn/IEONwz9o9l1i/k5o=; b=V1ckH/GsRf99S4tK4DJwDpFYoT8cCbnWZWUOSWzR25Ta0tcilqgrxxRwGoPOdu1q/C ZLjUnt8r7uDVq9dvDAMW3wqDz+9Z/gMJ4Q7M5d+HNOti1KmobHVdF3Pbz6dEqrHacHOR wwMvzbTmszcdQA/zsvT30ttUXtKYN4mTW9E/XoIr6Tu3xSqUY5kSFvyPchKh9sT21VkU 2WRCohG4nMWLDFUzm4VipCiKu4vFh/KGSg9YefTuGh8m2UMCv7lQvddytXUZgzetI86u qz5ItUFJPKVb4Q56r76oSQpCsngR07sMLrONVVzHOSLj5uehYHPfo71kqpqRwdgibobk phiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VQf8EKuL; 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 il16-20020a17090b165000b001ecfcc0a97dsi2387344pjb.71.2022.08.26.09.05.46; Fri, 26 Aug 2022 09:05:58 -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=VQf8EKuL; 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 S245080AbiHZPJc (ORCPT + 99 others); Fri, 26 Aug 2022 11:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244406AbiHZPJC (ORCPT ); Fri, 26 Aug 2022 11:09:02 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 760F6DD4EA for ; Fri, 26 Aug 2022 08:08:35 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id x26so1804505pfo.8 for ; Fri, 26 Aug 2022 08:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=rDCiGRameoc44J7lHWbl0JPQBn/IEONwz9o9l1i/k5o=; b=VQf8EKuL0X7CTzQMT9/lmQ+1rlvFbqSdWJ43L2omf4zYAogNVKx+E1+/4NxJWp71SJ upBbQVhWVUJgfYiXHlKIPENQcY4w5U5t2RiKYJ1PfGxVKiRSReXEYab8Qccb52pLO1Gz 9k6Yu3mGdHw96K7FOVQvnspayt0a1/FKDnVi8LZ03IepA9Ug+67nWgCGDqoT3JkI05xu nbk0SFMOuytiK/CcgApCgKitlSaJ+nc/lkDgP+Tj82x0OHPOdPl7qO+otN0tngOpDBh8 nQw21ypSGxxW1TEWOIRpqxxDz8wh9kWTKp1xo+SGr3tJ0u90VX3TrVPkKVczUhCGQoZz /e2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=rDCiGRameoc44J7lHWbl0JPQBn/IEONwz9o9l1i/k5o=; b=x2VXRBbnScIuGdX1jx4YWLBEuUFUuqPB6cCEFVUJX7RZuZoWGj5ckMs8xNePBRL8A1 lmpGcyqWt1D8jbl/k337veu6T6U3WrSy8nya6wtWt3jGVdKSE1bLqCxbW8LnXzgb0HrT kOvTuCs4auj0PZwwkfsTy2YTjBAmKfxfqE9PthPaxJ992nLXpPmRJbu1UIxL0iS0INRR J/DrpM8WfSXE8SFwQXRRvAI3qeOAHNzb+TkmNgdye+fmGYGja4sip09XAu30i1ICA+Yp B/wnOCCxJv8oWvX+kZ/4VrPRw9BCjrqTRhCuY2V7XCz18VaFiPj0kEOwf17tRrg0qYPX W24g== X-Gm-Message-State: ACgBeo1OtrfAkVfYiXO9UP1HRQ6529oKS+wkH79DGtIp0avzkxlPY/4y bfedN66UovaWyCCdM8PR5ChjGQ== X-Received: by 2002:a63:f704:0:b0:42b:7fa6:19bd with SMTP id x4-20020a63f704000000b0042b7fa619bdmr1671900pgh.283.1661526514860; Fri, 26 Aug 2022 08:08:34 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id z15-20020a170902cccf00b0016c0eb202a5sm1693664ple.225.2022.08.26.08.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 08:08:34 -0700 (PDT) Date: Fri, 26 Aug 2022 15:08:28 +0000 From: Sean Christopherson To: Xiaoyao Li Cc: Peter Zijlstra , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Paolo Bonzini , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [RFC PATCH 2/2] KVM: VMX: Stop/resume host PT before/after VM entry when PT_MODE_HOST_GUEST Message-ID: References: <20220825085625.867763-1-xiaoyao.li@intel.com> <20220825085625.867763-3-xiaoyao.li@intel.com> <6bcab33b-3fde-d470-88b9-7667c7dc4b2d@intel.com> <4e383b85-6777-4452-a073-4d2f439e28b1@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e383b85-6777-4452-a073-4d2f439e28b1@intel.com> X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,FSL_HELO_FAKE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 Fri, Aug 26, 2022, Xiaoyao Li wrote: > On 8/25/2022 11:59 PM, Sean Christopherson wrote: > > But ensuring the RTIT_CTL.TraceEn=0 is all that's needed to make VM-Entry happy, > > and if the host isn't using Intel PT, what do we care if other bits that, for all > > intents and purposes are ignored, are lost across VM-Entry/VM-Exit? I gotta > > imaging the perf will fully initialize RTIT_CTL if it starts using PT. > > Personally, I agree with it. > > But I'm not sure if there is a criteria that host context needs to be > unchanged after being virtualized. > > > Actually, if the host isn't actively using Intel PT, can KVM avoid saving the > > other RTIT MSRs? > > I don't think it's a good idea that it requires PT driver never and won't > rely on the previous value of PT MSRs. But it's OK if handing it over to > perf as the idea you gave below. Yep, my thought exactly. > > Even better, can we hand that off to perf? I really dislike KVM making assumptions > > about perf's internal behavior. E.g. can this be made to look like > > you mean let perf subsystem to do the context save/restore staff of host and > KVM focuses on save/restore of guest context, right? Yep! KVM already more or less does this for "regular" PMU MSRs, though in that case perf hands back a list of MSRs+data. But for Intel PT I don't see any point in having KVM do the actual MSR accesses. Tracing has to be turned off _before_ VM-Enter, so using the MSR load/save lists doesn't buy us anything. > I would like to see comment from perf folks on this and maybe need their > help on how to implement.