linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM/MMU: Simplify __kvm_sync_page() function
@ 2018-07-18  6:12 Tianyu Lan
  2018-07-18 11:29 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Tianyu Lan @ 2018-07-18  6:12 UTC (permalink / raw)
  Cc: Tianyu Lan, pbonzini, rkrcmar, tglx, mingo, hpa, x86, kvm, linux-kernel

Merge check of "sp->role.cr4_pae != !!is_pae(vcpu))" and "vcpu->
arch.mmu.sync_page(vcpu, sp) == 0". kvm_mmu_prepare_zap_page()
is called under both these conditions.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
 arch/x86/kvm/mmu.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index d594690d8b95..c2c1fd66fb36 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2117,12 +2117,8 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
 static bool __kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
 			    struct list_head *invalid_list)
 {
-	if (sp->role.cr4_pae != !!is_pae(vcpu)) {
-		kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
-		return false;
-	}
-
-	if (vcpu->arch.mmu.sync_page(vcpu, sp) == 0) {
+	if (sp->role.cr4_pae != !!is_pae(vcpu)
+	    || vcpu->arch.mmu.sync_page(vcpu, sp) == 0) {
 		kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
 		return false;
 	}
-- 
2.14.3

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

* Re: [PATCH] KVM/MMU: Simplify __kvm_sync_page() function
  2018-07-18  6:12 [PATCH] KVM/MMU: Simplify __kvm_sync_page() function Tianyu Lan
@ 2018-07-18 11:29 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2018-07-18 11:29 UTC (permalink / raw)
  To: Tianyu Lan; +Cc: rkrcmar, tglx, mingo, hpa, x86, kvm, linux-kernel

On 18/07/2018 08:12, Tianyu Lan wrote:
> Merge check of "sp->role.cr4_pae != !!is_pae(vcpu))" and "vcpu->
> arch.mmu.sync_page(vcpu, sp) == 0". kvm_mmu_prepare_zap_page()
> is called under both these conditions.
> 
> Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
> ---
>  arch/x86/kvm/mmu.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index d594690d8b95..c2c1fd66fb36 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -2117,12 +2117,8 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
>  static bool __kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
>  			    struct list_head *invalid_list)
>  {
> -	if (sp->role.cr4_pae != !!is_pae(vcpu)) {
> -		kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
> -		return false;
> -	}
> -
> -	if (vcpu->arch.mmu.sync_page(vcpu, sp) == 0) {
> +	if (sp->role.cr4_pae != !!is_pae(vcpu)
> +	    || vcpu->arch.mmu.sync_page(vcpu, sp) == 0) {
>  		kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
>  		return false;
>  	}
> 

Queued, thanks.

Paolo

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

end of thread, other threads:[~2018-07-18 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18  6:12 [PATCH] KVM/MMU: Simplify __kvm_sync_page() function Tianyu Lan
2018-07-18 11:29 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).