Commit 38a25b11 authored by Ben Gardon's avatar Ben Gardon Committed by Yu Zhang
Browse files

kvm: x86/mmu: Add existing trace points to TDP MMU

mainline inclusion
from mainline-v5.11-rc1
commit 33dd3574
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=33dd3574f5fef57c2c6caccf98925d63aa2a8d09

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

The TDP MMU was initially implemented without some of the usual
tracepoints found in mmu.c. Correct this discrepancy by adding the
missing trace points to the TDP MMU.

Tested: ran the demand paging selftest on an Intel Skylake machine with
	all the trace points used by the TDP MMU enabled and observed
	them firing with expected values.

This patch can be viewed in Gerrit at:
https://linux-review.googlesource.com/c/virt/kvm/kvm/+/3812



Signed-off-by: default avatarBen Gardon <bgardon@google.com>
Message-Id: <20201027175944.1183301-1-bgardon@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
parent c3521485
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
#include "tdp_mmu.h"
#include "spte.h"

#include <trace/events/kvm.h>

#ifdef CONFIG_X86_64
static bool __read_mostly tdp_mmu_enabled = false;
module_param_named(tdp_mmu, tdp_mmu_enabled, bool, 0644);
@@ -149,6 +151,8 @@ static struct kvm_mmu_page *alloc_tdp_mmu_page(struct kvm_vcpu *vcpu, gfn_t gfn,
	sp->gfn = gfn;
	sp->tdp_mmu_page = true;

	trace_kvm_mmu_get_page(sp, true);

	return sp;
}

@@ -319,6 +323,8 @@ static void __handle_changed_spte(struct kvm *kvm, int as_id, gfn_t gfn,
		pt = spte_to_child_pt(old_spte, level);
		sp = sptep_to_sp(pt);

		trace_kvm_mmu_prepare_zap_page(sp);

		list_del(&sp->link);

		if (sp->lpage_disallowed)
@@ -533,11 +539,13 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu, int write,
	if (unlikely(is_noslot_pfn(pfn))) {
		new_spte = make_mmio_spte(vcpu, iter->gfn, ACC_ALL);
		trace_mark_mmio_spte(iter->sptep, iter->gfn, new_spte);
	} else
	} else {
		make_spte_ret = make_spte(vcpu, ACC_ALL, iter->level, iter->gfn,
					 pfn, iter->old_spte, prefault, true,
					 map_writable, !shadow_accessed_mask,
					 &new_spte);
		trace_kvm_mmu_set_spte(iter->level, iter->gfn, iter->sptep);
	}

	if (new_spte == iter->old_spte)
		ret = RET_PF_SPURIOUS;
@@ -743,6 +751,8 @@ static int age_gfn_range(struct kvm *kvm, struct kvm_memory_slot *slot,

		tdp_mmu_set_spte_no_acc_track(kvm, &iter, new_spte);
		young = 1;

		trace_kvm_age_page(iter.gfn, iter.level, slot, young);
	}

	return young;