Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static struct kvm_lpage_info * lpage_info_slot(gfn_t gfn, const struct kvm_memory_slot *slot, int level) { unsigned long idx; idx = gfn_to_index(gfn, slot->base_gfn, level); return &slot->arch.lpage_info[level - 2][idx]; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void update_gfn_disallow_lpage_count(const struct kvm_memory_slot *slot, gfn_t gfn, int count) { struct kvm_lpage_info *linfo; int i; for (i = PG_LEVEL_2M; i <= KVM_MAX_HUGEPAGE_LEVEL; ++i) { linfo = lpage_info_slot(gfn, slot, i); linfo->disallow_lpage ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void kvm_mmu_gfn_allow_lpage(const struct kvm_memory_slot *slot, gfn_t gfn) { update_gfn_disallow_lpage_count(slot, gfn, -1); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void unaccount_huge_nx_page(struct kvm *kvm, struct kvm_mmu_page *sp) { --kvm->stat.nx_lpage_splits; sp->lpage_disallowed = false; list_del(&sp->lpage_disallowed_link); }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool rmap_can_add(struct kvm_vcpu *vcpu) { struct kvm_mmu_memory_cache *mc; mc = &vcpu->arch.mmu_pte_list_desc_cache; return kvm_mmu_memory_cache_nr_free_objects(mc); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool spte_wrprot_for_clear_dirty(u64 *sptep) { bool was_writable = test_and_clear_bit(PT_WRITABLE_SHIFT, (unsigned long *)sptep); if (was_writable && !spte_ad_enabled(*sptep)) kvm_set_pfn_dirty(spte_to_pfn(*sptep)); return was_writable; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool __rmap_clear_dirty(struct kvm *kvm, struct kvm_rmap_head *rmap_head, const struct kvm_memory_slot *slot) { u64 *sptep; struct rmap_iterator iter; bool flush = false; for_each_rmap_spte(rmap_head, &iter, sptep) if (spte_ad_need_write_protect(*sptep...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_mmu_clear_dirty_pt_masked(struct kvm *kvm, struct kvm_memory_slot *slot, gfn_t gfn_offset, unsigned long mask) { struct kvm_rmap_head *rmap_head; if (is_tdp_mmu_enabled(kvm)...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
int kvm_cpu_dirty_log_size(void) { return kvm_x86_ops.cpu_dirty_log_size; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool kvm_zap_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head, struct kvm_memory_slot *slot, gfn_t gfn, int level, pte_t unused) { return __kvm_zap_rmap(kvm, rmap_head, slot); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void slot_rmap_walk_init(struct slot_rmap_walk_iterator *iterator, const struct kvm_memory_slot *slot, int start_level, int end_level, gfn_t start_gfn, gfn_t end_gfn) { iterator->slot = slot; iterator->start_leve...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static __always_inline bool kvm_handle_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range, rmap_handler_t handler) { struct slot_rmap_walk_iterator iterator; bool ret = false; for_each_slot_rmap_range(range->sl...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range) { bool flush = false; if (kvm_memslots_have_rmaps(kvm)) flush = kvm_handle_gfn_range(kvm, range, kvm_zap_rmap); if (is_tdp_mmu_enabled(kvm)) flush = kvm_tdp_mmu_unmap_gfn_range(kvm, range, flush); return flush; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range) { bool flush = false; if (kvm_memslots_have_rmaps(kvm)) flush = kvm_handle_gfn_range(kvm, range, kvm_set_pte_rmap); if (is_tdp_mmu_enabled(kvm)) flush |= kvm_tdp_mmu_set_spte_gfn(kvm, range); return flush; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) { bool young = false; if (kvm_memslots_have_rmaps(kvm)) young = kvm_handle_gfn_range(kvm, range, kvm_age_rmap); if (is_tdp_mmu_enabled(kvm)) young |= kvm_tdp_mmu_age_gfn_range(kvm, range); return young; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int is_empty_shadow_page(u64 *spt) { u64 *pos; u64 *end; for (pos = spt, end = pos + PAGE_SIZE / sizeof(u64); pos != end; pos++) if (is_shadow_present_pte(*pos)) { printk(KERN_ERR "%s: %p %llx\n", __func__, pos, *pos); return 0; } return 1; } #endif
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, long nr) { kvm->arch.n_used_mmu_pages += nr; percpu_counter_add(&kvm_total_used_mmu_pages, nr); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_account_mmu_page(struct kvm *kvm, struct kvm_mmu_page *sp) { kvm_mod_used_mmu_pages(kvm, +1); kvm_account_pgtable_pages((void *)sp->spt, +1); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_unaccount_mmu_page(struct kvm *kvm, struct kvm_mmu_page *sp) { kvm_mod_used_mmu_pages(kvm, -1); kvm_account_pgtable_pages((void *)sp->spt, -1); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_mmu_free_shadow_page(struct kvm_mmu_page *sp) { MMU_WARN_ON(!is_empty_shadow_page(sp->spt)); hlist_del(&sp->hash_link); list_del(&sp->link); free_page((unsigned long)sp->spt); if (!sp->role.direct) free_page((unsigned long)sp->shadowed_translation); kmem_cache_free(mmu_page_header_cache...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void mmu_page_add_parent_pte(struct kvm_mmu_memory_cache *cache, struct kvm_mmu_page *sp, u64 *parent_pte) { if (!parent_pte) return; pte_list_add(cache, parent_pte, &sp->parent_ptes); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void drop_parent_pte(struct kvm_mmu_page *sp, u64 *parent_pte) { mmu_page_remove_parent_pte(sp, parent_pte); mmu_spte_clear_no_track(parent_pte); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static inline void clear_unsync_child_bit(struct kvm_mmu_page *sp, int idx) { --sp->unsync_children; WARN_ON((int)sp->unsync_children < 0); __clear_bit(idx, sp->unsync_child_bitmap); }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_unlink_unsync_page(struct kvm *kvm, struct kvm_mmu_page *sp) { WARN_ON(!sp->unsync); trace_kvm_mmu_sync_page(sp); sp->unsync = 0; --kvm->stat.mmu_unsync; }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool sp_has_gptes(struct kvm_mmu_page *sp) { if (sp->role.direct) return false; if (sp->role.passthrough) return false; return true; } #define for_each_valid_sp(_kvm, _sp, _list) \ hlist_for_each_entry(_sp, _list, ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, struct list_head *invalid_list) { int ret = vcpu->arch.mmu->sync_page(vcpu, sp); if (ret < 0) kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list); return ret; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool kvm_mmu_remote_flush_or_zap(struct kvm *kvm, struct list_head *invalid_list, bool remote_flush) { if (!remote_flush && list_empty(invalid_list)) return false; if (!list_empty(invalid_list)) kvm_mmu_commit_zap_page(...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int mmu_pages_next(struct kvm_mmu_pages *pvec, struct mmu_page_path *parents, int i) { int n; for (n = i + 1; n < pvec->nr; n++) { struct kvm_mmu_page *sp = pvec->page[n].sp; unsigned idx = pvec->page[n].idx; int level = sp->role.level; parents->idx[level - 1] = i...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int mmu_pages_first(struct kvm_mmu_pages *pvec, struct mmu_page_path *parents) { struct kvm_mmu_page *sp; int level; if (pvec->nr == 0) return 0; WARN_ON(pvec->page[0].idx != INVALID_INDEX); sp = pvec->page[0].sp; level = sp->role.level; WARN_ON(level == PG_LEVEL_4...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void mmu_pages_clear_parents(struct mmu_page_path *parents) { struct kvm_mmu_page *sp; unsigned int level = 0; do { unsigned int idx = parents->idx[level]; sp = parents->parent[level]; if (!sp) return; WARN_ON(idx == INVALID_INDEX); clear_unsync_child_bit(sp, idx); level++;...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int mmu_sync_children(struct kvm_vcpu *vcpu, struct kvm_mmu_page *parent, bool can_yield) { int i; struct kvm_mmu_page *sp; struct mmu_page_path parents; struct kvm_mmu_pages pages; LIST_HEAD(invalid_list); bool flush = false; while (mmu_unsync_walk(parent, &pages)) {...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void link_shadow_page(struct kvm_vcpu *vcpu, u64 *sptep, struct kvm_mmu_page *sp) { __link_shadow_page(vcpu->kvm, &vcpu->arch.mmu_pte_list_desc_cache, sptep, sp, true); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int mmu_page_zap_pte(struct kvm *kvm, struct kvm_mmu_page *sp, u64 *spte, struct list_head *invalid_list) { u64 pte; struct kvm_mmu_page *child; pte = *spte; if (is_shadow_present_pte(pte)) { if (is_last_spte(pte, sp->role.level)) { drop_spte(kvm, spte); } else ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_mmu_commit_zap_page(struct kvm *kvm, struct list_head *invalid_list) { struct kvm_mmu_page *sp, *nsp; if (list_empty(invalid_list)) return; kvm_flush_remote_tlbs(kvm); list_for_each_entry_safe(sp, nsp, invalid_list, link) { WARN_ON(!sp->role.invalid...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static inline unsigned long kvm_mmu_available_pages(struct kvm *kvm) { if (kvm->arch.n_max_mmu_pages > kvm->arch.n_used_mmu_pages) return kvm->arch.n_max_mmu_pages - kvm->arch.n_used_mmu_pages; return 0; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void disallowed_hugepage_adjust(struct kvm_page_fault *fault, u64 spte, int cur_level) { if (cur_level > PG_LEVEL_4K && cur_level == fault->goal_level && is_shadow_present_pte(spte) && !is_large_pte(spte)) { u64 page_mask = KVM_PAGES_PER_HPAGE(cur_level) - KVM_PAGES_...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static u64 *fast_pf_get_last_sptep(struct kvm_vcpu *vcpu, gpa_t gpa, u64 *spte) { struct kvm_shadow_walk_iterator iterator; u64 old_spte; u64 *sptep = NULL; for_each_shadow_entry_lockless(vcpu, gpa, iterator, old_spte) { sptep = iterator.sptep; *spte = old_spte; } ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void kvm_mmu_free_guest_mode_roots(struct kvm *kvm, struct kvm_mmu *mmu) { unsigned long roots_to_free = 0; hpa_t root_hpa; int i; WARN_ON_ONCE(mmu->root_role.guest_mode); for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) { root_hpa = mmu->prev_roots[i].hpa; if (!VALID_PAGE(root_hpa)) continue; ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int mmu_first_shadow_root_alloc(struct kvm *kvm) { struct kvm_memslots *slots; struct kvm_memory_slot *slot; int r = 0, i, bkt; if (kvm_shadow_root_allocated(kvm)) return 0; mutex_lock(&kvm->slots_arch_lock); /* Recheck, under the lock, whether this is the first shadow root. */ if (kvm_shado...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu) { int i; struct kvm_mmu_page *sp; if (vcpu->arch.mmu->root_role.direct) return; if (!VALID_PAGE(vcpu->arch.mmu->root.hpa)) return; vcpu_clear_mmio_info(vcpu, MMIO_GVA_ANY); if (vcpu->arch.mmu->cpu_role.base.level >= PT64_ROOT_4LEVEL) { hpa_t ro...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static u32 alloc_apf_token(struct kvm_vcpu *vcpu) { u32 id = vcpu->arch.apf.id; if (id << 12 == 0) vcpu->arch.apf.id = 1; return (vcpu->arch.apf.id++ << 12) | vcpu->vcpu_id; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) { if (shadow_memtype_mask && kvm_arch_has_noncoherent_dma(vcpu->kvm)) { for (; fault->max_level > PG_LEVEL_4K; --fault->max_level) { int page_num = KVM_PAGES_PER_HPAGE(fault->max_level); gfn_t base = (fault->addr >> PAGE_SHIF...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void update_pkru_bitmask(struct kvm_mmu *mmu) { unsigned bit; bool wp; mmu->pkru_mask = 0; if (!is_cr4_pke(mmu)) return; wp = is_cr0_wp(mmu); for (bit = 0; bit < ARRAY_SIZE(mmu->permissions); ++bit) { unsigned pfec, pkey_bits; bool check_pkey, check_write, ff, uf, wf, pte_user; p...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static union kvm_cpu_role kvm_calc_cpu_role(struct kvm_vcpu *vcpu, const struct kvm_mmu_role_regs *regs) { union kvm_cpu_role role = {0}; role.base.access = ACC_ALL; role.base.smm = is_smm(vcpu); role.base.guest_mode = is_guest_mode(vcpu); role.ext.valid = 1; if (!____is_cr0_pg(regs)) { role.base.dire...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void shadow_mmu_init_context(struct kvm_vcpu *vcpu, struct kvm_mmu *context, union kvm_cpu_role cpu_role, union kvm_mmu_page_role root_role) { if (cpu_role.as_u64 == context->cpu_role.as_u64 && ro...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void kvm_init_shadow_npt_mmu(struct kvm_vcpu *vcpu, unsigned long cr0, unsigned long cr4, u64 efer, gpa_t nested_cr3) { struct kvm_mmu *context = &vcpu->arch.guest_mmu; struct kvm_mmu_role_regs regs = { .cr0 = cr0, .cr4 = cr4 & ~X86_CR4_PKE, .efer = efer, }; union ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static union kvm_cpu_role kvm_calc_shadow_ept_root_page_role(struct kvm_vcpu *vcpu, bool accessed_dirty, bool execonly, u8 level) { union kvm_cpu_role role = {0}; WARN_ON_ONCE(is_smm(vcpu)); role.base.level = level; role.base.has_4_byte_gpte = false; role.base.direct = fals...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new, int bytes, struct kvm_page_track_notifier_node *node) { gfn_t gfn = gpa >> PAGE_SHIFT; struct kvm_mmu_page *sp; LIST_HEAD(invalid_list); u64 entry, gentry, *spte; int npte...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level, int tdp_max_root_level, int tdp_huge_page_level) { tdp_enabled = enable_tdp; tdp_root_level = tdp_forced_root_level; max_tdp_level = tdp_max_root_level; if (tdp_enabled) max_huge_page_level = tdp_huge_page_level; el...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void free_mmu_pages(struct kvm_mmu *mmu) { if (!tdp_enabled && mmu->pae_root) set_memory_encrypted((unsigned long)mmu->pae_root, 1); free_page((unsigned long)mmu->pae_root); free_page((unsigned long)mmu->pml4_root); free_page((unsigned long)mmu->pml5_root); }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_zap_obsolete_pages(struct kvm *kvm) { struct kvm_mmu_page *sp, *node; int nr_zapped, batch = 0; bool unstable; restart: list_for_each_entry_safe_reverse(sp, node, &kvm->arch.active_mmu_pages, link) { if (!is_obsolete_sp(kvm, sp)) break; /* ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool slot_rmap_write_protect(struct kvm *kvm, struct kvm_rmap_head *rmap_head, const struct kvm_memory_slot *slot) { return rmap_write_protect(rmap_head, false); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static struct kvm_mmu_page *shadow_mmu_get_sp_for_split(struct kvm *kvm, u64 *huge_sptep) { struct kvm_mmu_page *huge_sp = sptep_to_sp(huge_sptep); struct shadow_page_caches caches = {}; union kvm_mmu_page_role role; unsigned int access; gfn_t gfn; gf...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void shadow_mmu_split_huge_page(struct kvm *kvm, const struct kvm_memory_slot *slot, u64 *huge_sptep) { struct kvm_mmu_memory_cache *cache = &kvm->arch.split_desc_cache; u64 huge_spte = READ_ONCE(*huge_sptep); struct kvm_mmu_pag...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int shadow_mmu_try_split_huge_page(struct kvm *kvm, const struct kvm_memory_slot *slot, u64 *huge_sptep) { struct kvm_mmu_page *huge_sp = sptep_to_sp(huge_sptep); int level, r = 0; gfn_t gfn; u64 spte; gfn = kvm_mmu_pa...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm, struct kvm_rmap_head *rmap_head, const struct kvm_memory_slot *slot) { u64 *sptep; struct rmap_iterator iter; int need_tlb_flush = 0; struct kvm_mmu_page *sp; restart: f...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static void kvm_rmap_zap_collapsible_sptes(struct kvm *kvm, const struct kvm_memory_slot *slot) { if (slot_handle_level(kvm, slot, kvm_mmu_zap_collapsible_spte, PG_LEVEL_4K, KVM_MAX_HUGEPAGE_LEVEL - 1, true)) kvm_arch_flush_remote_tlbs_memslot(kv...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm, const struct kvm_memory_slot *memslot) { if (kvm_memslots_have_rmaps(kvm)) { write_lock(&kvm->mmu_lock); slot_handle_level_4k(kvm, memslot, __rmap_clear_dirty, false); write_unlock(&kvm->mmu_lock); } if (is_tdp_mm...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void kvm_mmu_zap_all(struct kvm *kvm) { struct kvm_mmu_page *sp, *node; LIST_HEAD(invalid_list); int ign; write_lock(&kvm->mmu_lock); restart: list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) { if (WARN_ON(sp->role.invalid)) continue; if (__kvm_mmu_prepare_zap_page(kvm, sp...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static bool get_nx_auto_mode(void) { return boot_cpu_has_bug(X86_BUG_ITLB_MULTIHIT) && !cpu_mitigations_off(); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
void __init kvm_mmu_x86_module_init(void) { if (nx_huge_pages == -1) __set_nx_huge_pages(get_nx_auto_mode()); kvm_mmu_spte_module_init(); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu.c
static int kvm_nx_lpage_recovery_worker(struct kvm *kvm, uintptr_t data) { u64 start_time; long remaining_time; while (true) { start_time = get_jiffies_64(); remaining_time = get_nx_lpage_recovery_timeout(start_time); set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop() && remai...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/mmu_internal.h
static inline bool is_nx_huge_page_enabled(struct kvm *kvm) { return READ_ONCE(nx_huge_pages) && !kvm->arch.disable_nx_huge_pages; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/page_track.c
void kvm_page_track_free_memslot(struct kvm_memory_slot *slot) { int i; for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) { kvfree(slot->arch.gfn_track[i]); slot->arch.gfn_track[i] = NULL; } }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/page_track.c
static inline bool page_track_mode_is_valid(enum kvm_page_track_mode mode) { if (mode < 0 || mode >= KVM_PAGE_TRACK_MAX) return false; return true; }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/page_track.c
int kvm_page_track_write_tracking_alloc(struct kvm_memory_slot *slot) { unsigned short *gfn_track; if (slot->arch.gfn_track[KVM_PAGE_TRACK_WRITE]) return 0; gfn_track = __vcalloc(slot->npages, sizeof(*gfn_track), GFP_KERNEL_ACCOUNT); if (gfn_track == NULL) return -ENOMEM; slot->arch.gfn_track[KVM_...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/page_track.c
void kvm_page_track_cleanup(struct kvm *kvm) { struct kvm_page_track_notifier_head *head; head = &kvm->arch.track_notifier_head; cleanup_srcu_struct(&head->track_srcu); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/paging_tmpl.h
static bool FNAME(prefetch_invalid_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, u64 *spte, u64 gpte) { if (!FNAME(is_present_gpte)(gpte)) goto no_present; if (PT_HAVE_ACCESSED_DIRTY(vcpu->arch.mmu) && !(gpte & PT_G...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/paging_tmpl.h
static inline bool FNAME(is_last_gpte)(struct kvm_mmu *mmu, unsigned int level, unsigned int gpte) { #if PTTYPE == 32 /* * 32-bit paging requires special handling because bit 7 is ignored if * CR4.PSE=0, not reserved. Clear bit 7 in the gpte if the level is * greater ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/paging_tmpl.h
static int FNAME(walk_addr)(struct guest_walker *walker, struct kvm_vcpu *vcpu, gpa_t addr, u64 access) { return FNAME(walk_addr_generic)(walker, vcpu, vcpu->arch.mmu, addr, access); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/paging_tmpl.h
static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw, u64 *sptep) { struct kvm_mmu_page *sp; pt_element_t *gptep = gw->prefetch_ptes; u64 *spte; int i; sp = sptep_to_sp(sptep); if (sp->role.level > PG_LEVEL_4K) return; if (unlikely(vcpu->kvm...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/paging_tmpl.h
static gpa_t FNAME(get_level1_sp_gpa)(struct kvm_mmu_page *sp) { int offset = 0; WARN_ON(sp->role.level != PG_LEVEL_4K); if (PTTYPE == 32) offset = sp->role.quadrant << SPTE_LEVEL_BITS; return gfn_to_gpa(sp->gfn) + offset * sizeof(pt_element_t); }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.c
u64 make_mmio_spte(struct kvm_vcpu *vcpu, u64 gfn, unsigned int access) { u64 gen = kvm_vcpu_memslots(vcpu)->generation & MMIO_SPTE_GEN_MASK; u64 spte = generation_mmio_spte_mask(gen); u64 gpa = gfn << PAGE_SHIFT; WARN_ON_ONCE(!shadow_mmio_value); access &= shadow_mmio_access_mask; spte |= shadow_mmio_va...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.c
bool spte_has_volatile_bits(u64 spte) { if (!is_writable_pte(spte) && is_mmu_writable_spte(spte)) return true; if (is_access_track_spte(spte)) return true; if (spte_ad_enabled(spte)) { if (!(spte & shadow_accessed_mask) || (is_writable_pte(spte) && !(spte & shadow_dirty_mask))) return...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.c
void kvm_mmu_set_mmio_spte_mask(u64 mmio_value, u64 mmio_mask, u64 access_mask) { BUG_ON((u64)(unsigned)access_mask != access_mask); WARN_ON(mmio_value & shadow_nonpresent_or_rsvd_lower_gfn_mask); enable_mmio_caching = allow_mmio_caching; if (!enable_mmio_caching) mmio_value...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.c
void kvm_mmu_set_ept_masks(bool has_ad_bits, bool has_exec_only) { shadow_user_mask = VMX_EPT_READABLE_MASK; shadow_accessed_mask = has_ad_bits ? VMX_EPT_ACCESS_BIT : 0ull; shadow_dirty_mask = has_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull; shadow_nx_mask = 0ull; shadow_x_mask = VMX_EPT_EXECUTABLE_MASK; shadow_pres...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline bool is_removed_spte(u64 spte) { return spte == REMOVED_SPTE; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline int spte_index(u64 *sptep) { return ((unsigned long)sptep / sizeof(*sptep)) & (SPTE_ENT_PER_PAGE - 1); }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline bool is_shadow_present_pte(u64 pte) { return !!(pte & SPTE_MMU_PRESENT_MASK); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline bool spte_ad_enabled(u64 spte) { MMU_WARN_ON(!is_shadow_present_pte(spte)); return (spte & SPTE_TDP_AD_MASK) != SPTE_TDP_AD_DISABLED_MASK; }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline u64 spte_shadow_accessed_mask(u64 spte) { MMU_WARN_ON(!is_shadow_present_pte(spte)); return spte_ad_enabled(spte) ? shadow_accessed_mask : 0; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline u64 spte_shadow_dirty_mask(u64 spte) { MMU_WARN_ON(!is_shadow_present_pte(spte)); return spte_ad_enabled(spte) ? shadow_dirty_mask : 0; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline bool is_large_pte(u64 pte) { return pte & PT_PAGE_SIZE_MASK; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline bool is_executable_pte(u64 spte) { return (spte & (shadow_x_mask | shadow_nx_mask)) == shadow_x_mask; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline bool is_accessed_spte(u64 spte) { u64 accessed_mask = spte_shadow_accessed_mask(spte); return accessed_mask ? spte & accessed_mask : !is_access_track_spte(spte); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline bool __is_bad_mt_xwr(struct rsvd_bits_validate *rsvd_check, u64 pte) { return rsvd_check->bad_mt_xwr & BIT_ULL(pte & 0x3f); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static __always_inline bool is_rsvd_spte(struct rsvd_bits_validate *rsvd_check, u64 spte, int level) { return __is_bad_mt_xwr(rsvd_check, spte) || __is_rsvd_bits_set(rsvd_check, spte, level); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/spte.h
static inline u64 get_mmio_spte_generation(u64 spte) { u64 gen; gen = (spte & MMIO_SPTE_GEN_LOW_MASK) >> MMIO_SPTE_GEN_LOW_SHIFT; gen |= (spte & MMIO_SPTE_GEN_HIGH_MASK) >> MMIO_SPTE_GEN_HIGH_SHIFT; return gen; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_iter.c
static gfn_t round_gfn_for_level(gfn_t gfn, int level) { return gfn & -KVM_PAGES_PER_HPAGE(level); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_iter.c
static bool try_step_up(struct tdp_iter *iter) { if (iter->level == iter->root_level) return false; iter->level++; iter->gfn = round_gfn_for_level(iter->gfn, iter->level); tdp_iter_refresh_sptep(iter); return true; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_iter.h
static inline u64 kvm_tdp_mmu_read_spte(tdp_ptep_t sptep) { return READ_ONCE(*rcu_dereference(sptep)); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_iter.h
static inline u64 kvm_tdp_mmu_write_spte_atomic(tdp_ptep_t sptep, u64 new_spte) { return xchg(rcu_dereference(sptep), new_spte); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_iter.h
static inline u64 kvm_tdp_mmu_write_spte(tdp_ptep_t sptep, u64 old_spte, u64 new_spte, int level) { if (is_shadow_present_pte(old_spte) && is_last_spte(old_spte, level) && spte_has_volatile_bits(old_spte)) return kvm_tdp_mmu_write_spte_atomic(sptep, new_spte); __...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
int kvm_mmu_init_tdp_mmu(struct kvm *kvm) { struct workqueue_struct *wq; if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled)) return 0; wq = alloc_workqueue("kvm", WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 0); if (!wq) return -ENOMEM; kvm->arch.tdp_mmu_enabled = true; INIT_LIST_HEAD(&kvm-...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static void tdp_mmu_zap_root_work(struct work_struct *work) { struct kvm_mmu_page *root = container_of(work, struct kvm_mmu_page, tdp_mmu_async_work); struct kvm *kvm = root->tdp_mmu_async_data; read_lock(&kvm->mmu_lock); tdp_mmu_zap_root(kvm, root, true); /* * Drop the refcount using kvm_tdp_mmu_...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static void tdp_mmu_init_sp(struct kvm_mmu_page *sp, tdp_ptep_t sptep, gfn_t gfn, union kvm_mmu_page_role role) { set_page_private(virt_to_page(sp->spt), (unsigned long)sp); sp->role = role; sp->gfn = gfn; sp->ptep = sptep; sp->tdp_mmu_page = true; trace_kvm_mmu_get_page(sp, t...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static void tdp_mmu_unlink_sp(struct kvm *kvm, struct kvm_mmu_page *sp, bool shared) { tdp_unaccount_mmu_page(kvm, sp); if (shared) spin_lock(&kvm->arch.tdp_mmu_pages_lock); else lockdep_assert_held_write(&kvm->mmu_lock); list_del(&sp->link); if (sp->lpage_disallowed) ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static u64 __tdp_mmu_set_spte(struct kvm *kvm, int as_id, tdp_ptep_t sptep, u64 old_spte, u64 new_spte, gfn_t gfn, int level, bool record_acc_track, bool record_dirty_log) { lockdep_assert_held_write(&kvm->mmu_lock); WARN_ON(is_removed_spte(old_spte) || i...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static inline void tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter, u64 new_spte) { _tdp_mmu_set_spte(kvm, iter, new_spte, true, true); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static inline gfn_t tdp_mmu_max_gfn_exclusive(void) { return kvm_mmu_max_gfn() + 1; }
[ 0, 0 ]