public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86/mmu: fix an incorrect comment in kvm_mmu_new_pgd
@ 2022-11-27 22:12 Wei Liu
  2022-11-28 18:02 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Liu @ 2022-11-27 22:12 UTC (permalink / raw)
  To: kvm
  Cc: Wei Liu, Sean Christopherson, Paolo Bonzini, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

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(-)

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
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86/mmu: fix an incorrect comment in kvm_mmu_new_pgd
  2022-11-27 22:12 [PATCH] KVM: x86/mmu: fix an incorrect comment in kvm_mmu_new_pgd Wei Liu
@ 2022-11-28 18:02 ` Sean Christopherson
  2022-11-28 21:39   ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2022-11-28 18:02 UTC (permalink / raw)
  To: Wei Liu
  Cc: kvm, Paolo Bonzini, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	H. Peter Anvin, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86/mmu: fix an incorrect comment in kvm_mmu_new_pgd
  2022-11-28 18:02 ` Sean Christopherson
@ 2022-11-28 21:39   ` Wei Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2022-11-28 21:39 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Wei Liu, kvm, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-28 21:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-27 22:12 [PATCH] KVM: x86/mmu: fix an incorrect comment in kvm_mmu_new_pgd Wei Liu
2022-11-28 18:02 ` Sean Christopherson
2022-11-28 21:39   ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox