Commit c736c66e authored by Sean Christopherson's avatar Sean Christopherson Committed by Yu Zhang
Browse files

KVM: Move prototypes for MMU notifier callbacks to generic code

mainline inclusion
from mainline-v5.13-rc1
commit 5f7c292b
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I7S3VQ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5f7c292b8975c9146063abbb91c0b9cdc1a5e9c5



Also, use the common declaration of kvm_unmap_hva_range() for loongarch,
instead of a private one. And change the definition for it.

Previously, loongarch's version of kvm_unmap_hva_range() defined "bool
blockable" as its last parameter(which is not used). But it is wrong.
KVM MMU uses "flag" of struct mmu_notifier_range as the argument when
it calls kvm_unmap_hva_range(), the arch code should use

	if (flag & MMU_NOTIFIER_RANGE_BLOCKABLE)

inside kvm_unmap_hva_range() when it wanna know if current operation
is a blockable one. So just fix the broken syntax for loongarch.

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

Move the prototypes for the MMU notifier callbacks out of arch code and
into common code.  There is no benefit to having each arch replicate the
prototypes since any deviation from the invocation in common code will
explode.

No functional change intended.

Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Message-Id: <20210326021957.1424875-9-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>

conflict:
	include/trace/events/kvm.h

Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
parent 42277895
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -525,11 +525,6 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
			      struct kvm_vcpu_events *events);

#define KVM_ARCH_WANT_MMU_NOTIFIER
int kvm_unmap_hva_range(struct kvm *kvm,
			unsigned long start, unsigned long end, unsigned flags);
int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);

void kvm_arm_halt_guest(struct kvm *kvm);
void kvm_arm_resume_guest(struct kvm *kvm);
+0 −5
Original line number Diff line number Diff line
@@ -298,11 +298,6 @@ enum _kvm_fault_result {
};

#define KVM_ARCH_WANT_MMU_NOTIFIER
int kvm_unmap_hva_range(struct kvm *kvm,
			unsigned long start, unsigned long end, bool blockable);
int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);

static inline void update_pc(struct kvm_vcpu_arch *arch)
{
+1 −1
Original line number Diff line number Diff line
@@ -712,7 +712,7 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gfn_t gfn, gfn_t gfn_end,
	return npages > 0;
}

int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end, bool blockable)
int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end, unsigned flags)
{
	unsigned long npages;

+0 −5
Original line number Diff line number Diff line
@@ -967,11 +967,6 @@ enum kvm_mips_fault_result kvm_trap_emul_gva_fault(struct kvm_vcpu *vcpu,
						   bool write);

#define KVM_ARCH_WANT_MMU_NOTIFIER
int kvm_unmap_hva_range(struct kvm *kvm,
			unsigned long start, unsigned long end, unsigned flags);
int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);

/* Emulation */
int kvm_get_inst(u32 *opc, struct kvm_vcpu *vcpu, u32 *out);
+0 −7
Original line number Diff line number Diff line
@@ -56,13 +56,6 @@

#define KVM_ARCH_WANT_MMU_NOTIFIER

extern int kvm_unmap_hva_range(struct kvm *kvm,
			       unsigned long start, unsigned long end,
			       unsigned flags);
extern int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
extern int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);

#define HPTEG_CACHE_NUM			(1 << 15)
#define HPTEG_HASH_BITS_PTE		13
#define HPTEG_HASH_BITS_PTE_LONG	12
Loading