Message ID | 20221127221245.204208-1-wei.liu@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5314168wrr; Sun, 27 Nov 2022 14:26:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf57cfZS9Se/wHHCSLOhLyDdTFtQIQl9FI2H+gA1C3ldJiKUS2X6FKWVDQkoAORAQwHO1r7U X-Received: by 2002:a17:907:c285:b0:7bb:c3c4:7a3b with SMTP id tk5-20020a170907c28500b007bbc3c47a3bmr14813770ejc.380.1669588018602; Sun, 27 Nov 2022 14:26:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669588018; cv=none; d=google.com; s=arc-20160816; b=p5Ldk+pCPru2YzUMWbmFBgov3ABVYVu99oCRHUAyQLlDQH6bOndLSgES5mYoX/SFO1 kY2HU50TNb4C1m7K3wiPTJtalD/eTHqu8OIXNnEGdaJTScCxPM4FbNZCRE+qd53P9msk yFJlzxdU/HDJDaxgaP/DNl0leU1gxaALIx/FuPN45A79hB/R7XpabYaliiFDR4eVEN// TB8JKJA8CiYBKwYAvzXAwwCl3s8WHHBn4JMFl6blncHAir2d7BJIAC0M1+7/OTtj5x9v FeWOeS6mVrR16J0vLf9nC8HInU4X0YSrtawTxx1q6pz79IrGrHnaf2NCJGt4+bdNS7Ww LMxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=H93P/+btHMmnUHfAxiUxxWr+DgQtxwEFifMZUFb22Lo=; b=VEyQ7SB5zQbbze3uVM+b2sl3LZsIueoDSmtg/AOHHG8v7NlsF03eowcv16p6V3o1Ht j5qSS0qbxlCBS7DHx8aYvlM4PIvoMLinejTu9bGhq8mw1n3IjOZV6zKrWIrPXxA97/R7 5WL4vlM9tnaYQJPu+9rlnG7S8czvOEkCq9jA6YSIVarU3hDUJk4ge13aNjULMdDACgN0 XkQhBvlSeq3raTcRPFDXeX2dn0u2Cz64Pij50TIoU1k/eU7iE9oRXOOt1HE4r1UF4dKM hjUr6qv6SRXtAlNpBbC+QIvbFcWCTYTlc82mAB0qjw79jyY0H6CtHC3kS5W/IrFvBGDP 6uUg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp37-20020a1709071b2500b007418a1e877dsi9384941ejc.580.2022.11.27.14.26.26; Sun, 27 Nov 2022 14:26:58 -0800 (PST) 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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbiK0WNB (ORCPT <rfc822;gah0developer@gmail.com> + 99 others); Sun, 27 Nov 2022 17:13:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiK0WM7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 27 Nov 2022 17:12:59 -0500 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E0BDF00; Sun, 27 Nov 2022 14:12:58 -0800 (PST) Received: by mail-wr1-f47.google.com with SMTP id w15so917322wrl.9; Sun, 27 Nov 2022 14:12:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=H93P/+btHMmnUHfAxiUxxWr+DgQtxwEFifMZUFb22Lo=; b=lVayMRecf2VR+UhFlsGcD8Z1eVqCI4RexZRzJ0tSxSfuI09yi1s6Llh330SCaGkDWR xQY2WdVHa3f3Fv6vmgohqXugBu4ghOT20gcoPHwS6BbaftOVzbGTku3PPhS4p9FfIGkE E1sDq5VCl2klUpEXCtJVLUBlY0Fat8Z375gg7jld8jN+P79p7T049Opka+axjvaGsi69 3rpyJVJ4Nc4FUfC8HxQu4ejeEup55KAo04mdmizUAnC/FqNxsRId3ZNnjugCeqnG7MWZ yQSzqxZ6k/qnvssaoU47J83CoeCoQfdlOfd9ZmFmI8BYbgxmwHd1bq2S6Vsm34R/trrz wibw== X-Gm-Message-State: ANoB5ploOPPpe4U2rli0TP662rxvgi+WrqlR+PGq9tUwbgDieK8hZAey H3bMG1wUER+KsdelPKC3syDb1WpMgaM= X-Received: by 2002:a05:6000:783:b0:241:bc34:3149 with SMTP id bu3-20020a056000078300b00241bc343149mr23821253wrb.351.1669587176312; Sun, 27 Nov 2022 14:12:56 -0800 (PST) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id m16-20020a05600c3b1000b003cfd0bd8c0asm14232298wms.30.2022.11.27.14.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 14:12:55 -0800 (PST) From: Wei Liu <wei.liu@kernel.org> To: kvm@vger.kernel.org Cc: Wei Liu <wei.liu@kernel.org>, Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" <hpa@zytor.com>, linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Subject: [PATCH] KVM: x86/mmu: fix an incorrect comment in kvm_mmu_new_pgd Date: Sun, 27 Nov 2022 22:12:45 +0000 Message-Id: <20221127221245.204208-1-wei.liu@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750689925815179930?= X-GMAIL-MSGID: =?utf-8?q?1750689925815179930?= |
Series |
KVM: x86/mmu: fix an incorrect comment in kvm_mmu_new_pgd
|
|
Commit Message
Wei Liu
Nov. 27, 2022, 10:12 p.m. UTC
There is no function named kvm_mmu_ensure_valid_pgd.
Fix the comment and remove the pair of braces to conform to Linux kernel
coding style.
Signed-off-by: Wei Liu <wei.liu@kernel.org>
---
arch/x86/kvm/mmu/mmu.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Comments
On Sun, Nov 27, 2022, Wei Liu wrote: > There is no function named kvm_mmu_ensure_valid_pgd. () when referecing functions, here and in the comment. > Fix the comment and remove the pair of braces to conform to Linux kernel > coding style. > > Signed-off-by: Wei Liu <wei.liu@kernel.org> > --- > arch/x86/kvm/mmu/mmu.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index b6f96d47e596..361574124fbe 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -4452,10 +4452,12 @@ void kvm_mmu_new_pgd(struct kvm_vcpu *vcpu, gpa_t new_pgd) > struct kvm_mmu *mmu = vcpu->arch.mmu; > union kvm_mmu_page_role new_role = mmu->root_role; > > - if (!fast_pgd_switch(vcpu->kvm, mmu, new_pgd, new_role)) { > - /* kvm_mmu_ensure_valid_pgd will set up a new root. */ > + /* > + * Return immediately if no usable root is found. A new root will be s/is/was And technically, it may not be a "new" root, e.g. if a different vCPU creates a usable root between now and kvm_mmu_reload(). > + * set up in vcpu_enter_guest prior to the next vmenter. s/vmenter/VM-Enter Pointing a reader at vcpu_enter_guest() isn't very helpful since that's a massive function; kvm_mmu_reload() is where the real magic happens. I generally prefer to avoid referencing functions in comments unless doing so is absolutely "necessary" because such comments always seem to become stale, but in this case I think it's worthwhile. /* * Return immediately if no usable was found, kvm_mmu_reload() will * establish a valid root prior to the next VM-Enter. */ > + */ > + if (!fast_pgd_switch(vcpu->kvm, mmu, new_pgd, new_role)) > return; > - } > > /* > * It's possible that the cached previous root page is obsolete because > -- > 2.35.1 >
On Mon, Nov 28, 2022 at 06:02:46PM +0000, Sean Christopherson wrote: > On Sun, Nov 27, 2022, Wei Liu wrote: > > There is no function named kvm_mmu_ensure_valid_pgd. > > () when referecing functions, here and in the comment. > > > Fix the comment and remove the pair of braces to conform to Linux kernel > > coding style. > > > > Signed-off-by: Wei Liu <wei.liu@kernel.org> > > --- > > arch/x86/kvm/mmu/mmu.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > index b6f96d47e596..361574124fbe 100644 > > --- a/arch/x86/kvm/mmu/mmu.c > > +++ b/arch/x86/kvm/mmu/mmu.c > > @@ -4452,10 +4452,12 @@ void kvm_mmu_new_pgd(struct kvm_vcpu *vcpu, gpa_t new_pgd) > > struct kvm_mmu *mmu = vcpu->arch.mmu; > > union kvm_mmu_page_role new_role = mmu->root_role; > > > > - if (!fast_pgd_switch(vcpu->kvm, mmu, new_pgd, new_role)) { > > - /* kvm_mmu_ensure_valid_pgd will set up a new root. */ > > + /* > > + * Return immediately if no usable root is found. A new root will be > > s/is/was > > And technically, it may not be a "new" root, e.g. if a different vCPU creates a > usable root between now and kvm_mmu_reload(). > > > + * set up in vcpu_enter_guest prior to the next vmenter. > > s/vmenter/VM-Enter > > Pointing a reader at vcpu_enter_guest() isn't very helpful since that's a massive > function; kvm_mmu_reload() is where the real magic happens. I generally prefer to > avoid referencing functions in comments unless doing so is absolutely "necessary" > because such comments always seem to become stale, but in this case I think it's > worthwhile. > > /* > * Return immediately if no usable was found, kvm_mmu_reload() will > * establish a valid root prior to the next VM-Enter. > */ > Thanks for the feedback. v2 coming shortly. Thanks, Wei.
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index b6f96d47e596..361574124fbe 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4452,10 +4452,12 @@ void kvm_mmu_new_pgd(struct kvm_vcpu *vcpu, gpa_t new_pgd) struct kvm_mmu *mmu = vcpu->arch.mmu; union kvm_mmu_page_role new_role = mmu->root_role; - if (!fast_pgd_switch(vcpu->kvm, mmu, new_pgd, new_role)) { - /* kvm_mmu_ensure_valid_pgd will set up a new root. */ + /* + * Return immediately if no usable root is found. A new root will be + * set up in vcpu_enter_guest prior to the next vmenter. + */ + if (!fast_pgd_switch(vcpu->kvm, mmu, new_pgd, new_role)) return; - } /* * It's possible that the cached previous root page is obsolete because