mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] LoongArch: KVM: Remove redundant assignment in kvm_map_page_fast
@ 2024-07-13 15:59 tangbin
  2024-07-26  2:13 ` maobibo
  0 siblings, 1 reply; 2+ messages in thread
From: tangbin @ 2024-07-13 15:59 UTC (permalink / raw)
  To: zhaotianrui, maobibo, chenhuacai, kernel
  Cc: kvm, loongarch, linux-kernel, tangbin

In the function kvm_map_page_fast, the assignment of 'ret' is
redundant, so remove it.

Signed-off-by: tangbin <tangbin@cmss.chinamobile.com>
---
 arch/loongarch/kvm/mmu.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/arch/loongarch/kvm/mmu.c b/arch/loongarch/kvm/mmu.c
index 2634a9e8d..d6c922a4a 100644
--- a/arch/loongarch/kvm/mmu.c
+++ b/arch/loongarch/kvm/mmu.c
@@ -551,7 +551,6 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
  */
 static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool write)
 {
-	int ret = 0;
 	kvm_pfn_t pfn = 0;
 	kvm_pte_t *ptep, changed, new;
 	gfn_t gfn = gpa >> PAGE_SHIFT;
@@ -563,20 +562,16 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
 
 	/* Fast path - just check GPA page table for an existing entry */
 	ptep = kvm_populate_gpa(kvm, NULL, gpa, 0);
-	if (!ptep || !kvm_pte_present(NULL, ptep)) {
-		ret = -EFAULT;
+	if (!ptep || !kvm_pte_present(NULL, ptep))
 		goto out;
-	}
 
 	/* Track access to pages marked old */
 	new = kvm_pte_mkyoung(*ptep);
 	/* call kvm_set_pfn_accessed() after unlock */
 
 	if (write && !kvm_pte_dirty(new)) {
-		if (!kvm_pte_write(new)) {
-			ret = -EFAULT;
+		if (!kvm_pte_write(new))
 			goto out;
-		}
 
 		if (kvm_pte_huge(new)) {
 			/*
@@ -584,10 +579,8 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
 			 * enabled for HugePages
 			 */
 			slot = gfn_to_memslot(kvm, gfn);
-			if (kvm_slot_dirty_track_enabled(slot)) {
-				ret = -EFAULT;
+			if (kvm_slot_dirty_track_enabled(slot))
 				goto out;
-			}
 		}
 
 		/* Track dirtying of writeable pages */
@@ -615,10 +608,10 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
 		if (page)
 			put_page(page);
 	}
-	return ret;
+	return 0;
 out:
 	spin_unlock(&kvm->mmu_lock);
-	return ret;
+	return -EFAULT;
 }
 
 static bool fault_supports_huge_mapping(struct kvm_memory_slot *memslot,
-- 
2.18.4




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

end of thread, other threads:[~2024-07-26  2:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-13 15:59 [PATCH] LoongArch: KVM: Remove redundant assignment in kvm_map_page_fast tangbin
2024-07-26  2:13 ` maobibo

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

all inboxes | Powered by JetHome®