Commit f5028f02 authored by Yu Jiayi's avatar Yu Jiayi Committed by guzitao
Browse files

sw64: kvm: optimize the calling and implementation of functions in mmu.c

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB73UR



--------------------------------

This patch:
    - The kvm_set_pfn_accessed() calls kvm_set_page_accessed(), and the
      kvm_release_pfn_clean() eventually calls kvm_set_page_accessed()
      too. So, remove the redundant call to kvm_set_pfn_accessed().
    - Move the functionality of kvm_mmu_write_protect_pt_masked() into
      its caller, kvm_arch_mmu_enable_log_dirty_pt_masked(). This will
      be used to share some of the code.

Signed-off-by: default avatarYu Jiayi <yujiayi@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 991e767d
Loading
Loading
Loading
Loading
+7 −21
Original line number Diff line number Diff line
@@ -1358,7 +1358,6 @@ static int user_mem_abort(struct kvm_vcpu *vcpu,

out_unlock:
	spin_unlock(&kvm->mmu_lock);
	kvm_set_pfn_accessed(pfn);
	kvm_release_pfn_clean(pfn);
	return ret;
}
@@ -1513,18 +1512,19 @@ bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
	return false;
}

/**
 * kvm_mmu_write_protect_pt_masked() - write protect dirty pages

/*
 * kvm_arch_mmu_enable_log_dirty_pt_masked - enable dirty logging for selected pages.
 * @kvm:	The KVM pointer
 * @slot:	The memory slot associated with mask
 * @gfn_offset:	The gfn offset in memory slot
 * @mask:	The mask of dirty pages at offset 'gfn_offset' in this memory
 *		slot to be write protected
 * @mask:	The mask of pages at offset 'gfn_offset' in this memory
 *		slot to enable dirty logging on
 *
 * Walks bits set in mask write protects the associated pte's. Caller must
 * Write protect selected pages to enable dirty logging for them. Caller must
 * acquire kvm_mmu_lock.
 */
static void kvm_mmu_write_protect_pt_masked(struct kvm *kvm,
void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
		struct kvm_memory_slot *slot,
		gfn_t gfn_offset, unsigned long mask)
{
@@ -1534,17 +1534,3 @@ static void kvm_mmu_write_protect_pt_masked(struct kvm *kvm,

	apt_wp_range(kvm, start, end);
}

/*
 * kvm_arch_mmu_enable_log_dirty_pt_masked - enable dirty logging for selected
 * dirty pages.
 *
 * It calls kvm_mmu_write_protect_pt_masked to write protect selected pages to
 * enable dirty logging for them.
 */
void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
		struct kvm_memory_slot *slot,
		gfn_t gfn_offset, unsigned long mask)
{
	kvm_mmu_write_protect_pt_masked(kvm, slot, gfn_offset, mask);
}