Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp15938pxb; Wed, 30 Mar 2022 21:32:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVpsRTg6LlWvz+qHs3NhLa62ZcKDY714WB6u0bydREATelifXfuNsfM+OMUOmv9K01EBE/ X-Received: by 2002:a17:90b:3e8c:b0:1c7:3001:f359 with SMTP id rj12-20020a17090b3e8c00b001c73001f359mr3833279pjb.179.1648701169477; Wed, 30 Mar 2022 21:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648701169; cv=none; d=google.com; s=arc-20160816; b=ZnDf9EwUt7L0lIbRpDPxEtNX7tKdgy7jFiqYzR4GFuPe7oE9nmjP93NB+2kJiaA/QV QqP5DESNL8WeDdmp5PkUEI3S3v9hEgw1eJ1+K5abThEARTvhLgb0IsxEgudzc+taUEWi pUxd50QV2/F8S6GTCog0iNQu1/huRe4gfehymZjZqQIU6dX49/YON3CRZ8iJzNCfnepk IuzDsMgcGpxnBIArKsHxPk9BKtCnKdzc+vD8AASGB04DzZrnvVgHhW8LMiA5+1ixAk8a 6emxrufABcATCCL+92Q5K5V3Kb8VWxnBOeEPqlHBWibqyv0PYgeZVUD76n835ADNKgHB zzdw== 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=G2Eo6r97owDtczFfVpJgXwuwxzvJje+iY5MUwcbp6hw=; b=f9NPjR5XRMmywAebZscP3UTiWyWFvBCSzJ6t9DReqIcxTVm3AvkHv3J0nrtnU/rG6Z 7Py0ZTempXgV9tD6bBuuB6VwFfNbBGb8xMhy5aZvyEmqNtLL+JBMHc+NyBaEgNPKgldo NrPyl1B4bNfizCi4np3dCyxhfk67FLkSbUd8DBPedghlJqiAt9DmSq+6fsK36ut87VJ0 2s9gfVJz8IK2E9zri8ThoOozjkFqqm8gbp5/Mz3vWnu1+jwoUNb6K03whxg8HZKNUD9m DKzNwodSiYOvFzgBqktBcAU5Upbml/hMu3M5rKlqhL2L2vLs+M0nuCf+/Y+bTRpOt/He 1WOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZyVdrFUS; 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 h3-20020a170902680300b00153b2d165a7si20341303plk.431.2022.03.30.21.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:32:49 -0700 (PDT) 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=ZyVdrFUS; 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 8FB881DEA8B; Wed, 30 Mar 2022 20:25:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351092AbiC3Uoo (ORCPT + 99 others); Wed, 30 Mar 2022 16:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351086AbiC3Uom (ORCPT ); Wed, 30 Mar 2022 16:44:42 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B0944A27 for ; Wed, 30 Mar 2022 13:42:57 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id c23so21607804plo.0 for ; Wed, 30 Mar 2022 13:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=G2Eo6r97owDtczFfVpJgXwuwxzvJje+iY5MUwcbp6hw=; b=ZyVdrFUSHODjAn6lXuymsg1JdqIUb6/sjDeEVqnj8cdu+O4oEfaI7fgVObXyWbl0gz HmiqDpTQiUePxaehF25QdacbwMcQ2C5KxkCoX+CptKY7WzMaFdEwdDnGHLq4NlmVhgqT aNF9pxUjNnz7RpHHm/3pz187Q5TnIWJJLg/SeanGydlc4aOHohQy8VUAgQK6AYF0w4xw /V4ZhjaE46mj+17Aq/Q6HXbV7HsFqo4Pq99AilRX1iHDtHL6kyBrbsg7YJFvgZ93I+da E+b0lWq3jcosPIyWLPnOF0gkXl3wnyJsK07zMBfljy0RGM9rQ0poX38AWEV/VM7/orBq yafA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=G2Eo6r97owDtczFfVpJgXwuwxzvJje+iY5MUwcbp6hw=; b=u3la0Dn6IdjEI/l5fTBLxc+0qsjtOok3m1U/fN6AL10ytSVU/viy2gOSYTE+CFeDH4 XH6pp5iFRLZw8V1YBQFkfas1AT47iRXMDEbpKTGtzbLWXG+dBvxhr+BhLcAM1xkhVcLw 9V8ot4Ajbq86jcUpyzBOO3HJfklkV59s+qDNEdFsYmr3TMqRa2GKpkHQD7MozW5uwoB8 weGQOjs2NqxmggrSwe4AqmqHhyXPpW3OqDyigfgbrWxgTdwTPuagTQJWA9MQnpCCHNTr yC3FmQ7OGi4GNvN3LWDEiCUh0qsY1M/Au1z2Fx2HgjOzBfmPKUzLgqWd4a3pJbSiqLXX bRdQ== X-Gm-Message-State: AOAM530UCpuH/u9viglMtZuEgR0kdYeJPgHOJSicn5LBxJ2sUqgXycLB f4XSz7Zd/Gw+v5KSj/iVqjv7H6ED0bl7Sg== X-Received: by 2002:a17:90b:4c41:b0:1c7:3fa8:9b6a with SMTP id np1-20020a17090b4c4100b001c73fa89b6amr1660523pjb.120.1648672976582; Wed, 30 Mar 2022 13:42:56 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id a11-20020a056a000c8b00b004fade889fb3sm26069455pfv.18.2022.03.30.13.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 13:42:55 -0700 (PDT) Date: Wed, 30 Mar 2022 20:42:52 +0000 From: Sean Christopherson To: Chenyi Qiang Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Xiaoyao Li , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/7] KVM: VMX: Add proper cache tracking for PKRS Message-ID: References: <20220221080840.7369-1-chenyi.qiang@intel.com> <20220221080840.7369-3-chenyi.qiang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220221080840.7369-3-chenyi.qiang@intel.com> 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 Mon, Feb 21, 2022, Chenyi Qiang wrote: > Add PKRS caching into the standard register caching mechanism in order > to take advantage of the availability checks provided by regs_avail. > > This is because vcpu->arch.pkrs will be rarely acceesed by KVM, only in > the case of host userspace MSR reads and GVA->GPA translation in > following patches. It is unnecessary to keep it up-to-date at all times. It might be worth throwing in a blurb that the potential benefits of this caching are tenous. Barring userspace wierdness, the MSR read is not a hot path. permission_fault() is slightly more common, but I would be surprised if caching actually provides meaningful performance benefit. The PKRS checks are done only once per virtual access, i.e. only on the final translation, so the cache will get a hit if and only if there are multiple translations in a single round of emulation, where a "round of emulation" ends upon entry to the guest. With unrestricted guest, i.e. for all intents and purposes every VM using PKRS, there aren't _that_ many scenarios where KVM will (a) emulate in the first place and (b) emulate enough accesses for the caching to be meaningful. That said, this is basically "free", so I've no objection to adding it. But I do think it's worth documenting that it's nice-to-have so that we don't hesitate to rip it out in the future if there's a strong reason to drop the caching. > Signed-off-by: Chenyi Qiang > --- Reviewed-by: Sean Christopherson