Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
void kvm_tdp_mmu_invalidate_all_roots(struct kvm *kvm) { struct kvm_mmu_page *root; lockdep_assert_held_write(&kvm->mmu_lock); list_for_each_entry(root, &kvm->arch.tdp_mmu_roots, link) { if (!root->role.invalid && !WARN_ON_ONCE(!kvm_tdp_mmu_get_root(root))) { root->role.invalid = true; tdp_mmu_sc...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range, bool flush) { return kvm_tdp_mmu_zap_leafs(kvm, range->slot->as_id, range->start, range->end, range->may_block, flush); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
bool kvm_tdp_mmu_age_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range) { return kvm_tdp_mmu_handle_gfn(kvm, range, age_gfn_range); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static bool set_spte_gfn(struct kvm *kvm, struct tdp_iter *iter, struct kvm_gfn_range *range) { u64 new_spte; WARN_ON(pte_huge(range->pte) || range->start + 1 != range->end); if (iter->level != PG_LEVEL_4K || !is_shadow_present_pte(iter->old_spte)) return false; /* * Note, whe...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
bool kvm_tdp_mmu_wrprot_slot(struct kvm *kvm, const struct kvm_memory_slot *slot, int min_level) { struct kvm_mmu_page *root; bool spte_set = false; lockdep_assert_held_read(&kvm->mmu_lock); for_each_valid_tdp_mmu_root_yield_safe(kvm, root, slot->as_id...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static int tdp_mmu_split_huge_pages_root(struct kvm *kvm, struct kvm_mmu_page *root, gfn_t start, gfn_t end, int target_level, bool shared) { struct kvm_mmu_page *sp = NULL; struct tdp_iter ite...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.c
static bool write_protect_gfn(struct kvm *kvm, struct kvm_mmu_page *root, gfn_t gfn, int min_level) { struct tdp_iter iter; u64 new_spte; bool spte_set = false; BUG_ON(min_level > KVM_MAX_HUGEPAGE_LEVEL); rcu_read_lock(); for_each_tdp_pte_min_level(iter, root, min_level, gfn...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.h
__must_check static inline bool kvm_tdp_mmu_get_root(struct kvm_mmu_page *root) { return refcount_inc_not_zero(&root->tdp_mmu_root_count); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.h
static inline void kvm_tdp_mmu_walk_lockless_begin(void) { rcu_read_lock(); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.h
static inline int kvm_mmu_init_tdp_mmu(struct kvm *kvm) { return 0; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.h
static inline bool is_tdp_mmu_page(struct kvm_mmu_page *sp) { return false; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu/tdp_mmu.h
static inline bool is_tdp_mmu(struct kvm_mmu *mmu) { return false; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu.h
static __always_inline u64 rsvd_bits(int s, int e) { BUILD_BUG_ON(__builtin_constant_p(e) && __builtin_constant_p(s) && e < s); if (__builtin_constant_p(e)) BUILD_BUG_ON(e > 63); else e &= 63; if (e < s) return 0; return ((2ULL << (e - s)) - 1) << s; }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mmu.h
static inline gfn_t kvm_mmu_max_gfn(void) { int max_gpa_bits = likely(tdp_enabled) ? shadow_phys_bits : 52; return (1ULL << (max_gpa_bits - PAGE_SHIFT)) - 1; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu.h
static inline void kvm_mmu_load_pgd(struct kvm_vcpu *vcpu) { u64 root_hpa = vcpu->arch.mmu->root.hpa; if (!VALID_PAGE(root_hpa)) return; static_call(kvm_x86_load_mmu_pgd)(vcpu, root_hpa, vcpu->arch.mmu->root_role.level); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu.h
static inline bool is_tdp_mmu_enabled(struct kvm *kvm) { return false; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mmu.h
static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level) { return (gfn >> KVM_HPAGE_GFN_SHIFT(level)) - (base_gfn >> KVM_HPAGE_GFN_SHIFT(level)); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
bool kvm_mtrr_valid(struct kvm_vcpu *vcpu, u32 msr, u64 data) { int i; u64 mask; if (!msr_mtrr_valid(msr)) return false; if (msr == MSR_IA32_CR_PAT) { return kvm_pat_valid(data); } else if (msr == MSR_MTRRdefType) { if (data & ~0xcff) return false; return valid_mtrr_type(data & 0xff); ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static bool mtrr_is_enabled(struct kvm_mtrr *mtrr_state) { return !!(mtrr_state->deftype & IA32_MTRR_DEF_TYPE_E); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static u64 fixed_mtrr_seg_unit_size(int seg) { return 8 << fixed_seg_table[seg].range_shift; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static int fixed_msr_to_range_index(u32 msr) { int seg, unit; if (!fixed_msr_to_seg_unit(msr, &seg, &unit)) return -1; return fixed_mtrr_seg_unit_range_index(seg, unit); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
int kvm_mtrr_set_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data) { int index; if (!kvm_mtrr_valid(vcpu, msr, data)) return 1; index = fixed_msr_to_range_index(msr); if (index >= 0) *(u64 *)&vcpu->arch.mtrr_state.fixed_ranges[index] = data; else if (msr == MSR_MTRRdefType) vcpu->arch.mtrr_state.de...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata) { int index; if (msr == MSR_MTRRcap) { /* * SMRR = 0 * WC = 1 * FIX = 1 * VCNT = KVM_NR_VAR_MTRR */ *pdata = 0x500 | KVM_NR_VAR_MTRR; return 0; } if (!msr_mtrr_valid(msr)) return 1; index = fixed_msr_t...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static bool mtrr_lookup_fixed_start(struct mtrr_iter *iter) { int seg, index; if (!fixed_mtrr_is_enabled(iter->mtrr_state)) return false; seg = fixed_mtrr_addr_to_seg(iter->start); if (seg < 0) return false; iter->fixed = true; index = fixed_mtrr_addr_seg_to_range_index(iter->start, seg); iter...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static bool match_var_range(struct mtrr_iter *iter, struct kvm_mtrr_range *range) { u64 start, end; var_mtrr_range(range, &start, &end); if (!(start >= iter->end || end <= iter->start)) { iter->range = range; iter->partial_map |= iter->start_max < start; /* update the ma...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static void __mtrr_lookup_var_next(struct mtrr_iter *iter) { struct kvm_mtrr *mtrr_state = iter->mtrr_state; list_for_each_entry_continue( iter->range, &mtrr_state->head, node) if (match_var_range(iter, iter->range)) return; iter->range = NULL; iter->partial_map |= iter->start_max < iter->end; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static void mtrr_lookup_var_next(struct mtrr_iter *iter) { __mtrr_lookup_var_next(iter); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static bool mtrr_lookup_okay(struct mtrr_iter *iter) { if (iter->fixed) { iter->mem_type = iter->mtrr_state->fixed_ranges[iter->index]; return true; } if (iter->range) { iter->mem_type = iter->range->base & 0xff; return true; } return false; }
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/mtrr.c
static void mtrr_lookup_next(struct mtrr_iter *iter) { if (iter->fixed) mtrr_lookup_fixed_next(iter); else mtrr_lookup_var_next(iter); } #define mtrr_for_each_mem_type(_iter_, _mtrr_, _gpa_start_, _gpa_end_) \ for (mtrr_lookup_init(_iter_, _mtrr_, _gpa_start_, _gpa_end_); \ ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
void kvm_pmu_ops_update(const struct kvm_pmu_ops *pmu_ops) { memcpy(&kvm_pmu_ops, pmu_ops, sizeof(kvm_pmu_ops)); #define __KVM_X86_PMU_OP(func) \ static_call_update(kvm_x86_pmu_##func, kvm_pmu_ops.func); #define KVM_X86_PMU_OP(func) ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
static inline void __kvm_perf_overflow(struct kvm_pmc *pmc, bool in_pmi) { struct kvm_pmu *pmu = pmc_to_pmu(pmc); bool skip_pmi = false; if (test_and_set_bit(pmc->idx, pmu->reprogram_pmi)) return; if (pmc->perf_event && pmc->perf_event->attr.precise_ip) { if (!in_pmi) { /* * TODO: KVM is ...
[ 1, 1 ]
Linux Kernel
arch/x86/kvm/pmu.c
static void kvm_perf_overflow(struct perf_event *perf_event, struct perf_sample_data *data, struct pt_regs *regs) { struct kvm_pmc *pmc = perf_event->overflow_handler_context; __kvm_perf_overflow(pmc, true); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
static int cmp_u64(const void *pa, const void *pb) { u64 a = *(u64 *)pa; u64 b = *(u64 *)pb; return (a > b) - (a < b); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
static bool check_pmu_event_filter(struct kvm_pmc *pmc) { struct kvm_pmu_event_filter *filter; struct kvm *kvm = pmc->vcpu->kvm; bool allow_event = true; __u64 key; int idx; if (!static_call(kvm_x86_pmu_hw_event_available)(pmc)) return false; filter = srcu_dereference(kvm->arch.pmu_event_filter, &k...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
bool kvm_pmu_is_valid_rdpmc_ecx(struct kvm_vcpu *vcpu, unsigned int idx) { return static_call(kvm_x86_pmu_is_valid_rdpmc_ecx)(vcpu, idx); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
static int kvm_pmu_rdpmc_vmware(struct kvm_vcpu *vcpu, unsigned idx, u64 *data) { u64 ctr_val; switch (idx) { case VMWARE_BACKDOOR_PMC_HOST_TSC: ctr_val = rdtsc(); break; case VMWARE_BACKDOOR_PMC_REAL_TIME: ctr_val = ktime_get_boottime_ns(); break; case VMWARE...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned idx, u64 *data) { bool fast_mode = idx & (1u << 31); struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); struct kvm_pmc *pmc; u64 mask = fast_mode ? ~0u : ~0ull; if (!pmu->version) return 1; if (is_vmware_backdoor_pmc(idx)) return kvm_pmu_rdpmc_vmware(vcpu, ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
int kvm_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) { return static_call(kvm_x86_pmu_get_msr)(vcpu, msr_info); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
void kvm_pmu_refresh(struct kvm_vcpu *vcpu) { static_call(kvm_x86_pmu_refresh)(vcpu); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
void kvm_pmu_destroy(struct kvm_vcpu *vcpu) { kvm_pmu_reset(vcpu); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.c
void kvm_pmu_trigger_event(struct kvm_vcpu *vcpu, u64 perf_hw_id) { struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); struct kvm_pmc *pmc; int i; for_each_set_bit(i, pmu->all_valid_pmc_idx, X86_PMC_IDX_MAX) { pmc = static_call(kvm_x86_pmu_pmc_idx_to_pmc)(pmu, i); if (!pmc || !pmc_is_enabled(pmc) || !pmc_specul...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.h
static inline void pmc_release_perf_event(struct kvm_pmc *pmc) { if (pmc->perf_event) { perf_event_release_kernel(pmc->perf_event); pmc->perf_event = NULL; pmc->current_config = 0; pmc_to_pmu(pmc)->event_count--; } }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.h
static inline void pmc_stop_counter(struct kvm_pmc *pmc) { if (pmc->perf_event) { pmc->counter = pmc_read_counter(pmc); pmc_release_perf_event(pmc); } }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.h
static inline bool pmc_is_gp(struct kvm_pmc *pmc) { return pmc->type == KVM_PMC_GP; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/pmu.h
static inline bool pmc_speculative_in_use(struct kvm_pmc *pmc) { struct kvm_pmu *pmu = pmc_to_pmu(pmc); if (pmc_is_fixed(pmc)) return fixed_ctrl_field(pmu->fixed_ctr_ctrl, pmc->idx - INTEL_PMC_IDX_FIXED) & 0x3; return pmc->eventsel & ARCH_PERFMON_EVENTSEL_ENABLE; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/reverse_cpuid.h
static __always_inline void reverse_cpuid_check(unsigned int x86_leaf) { BUILD_BUG_ON(x86_leaf == CPUID_LNX_1); BUILD_BUG_ON(x86_leaf == CPUID_LNX_2); BUILD_BUG_ON(x86_leaf == CPUID_LNX_3); BUILD_BUG_ON(x86_leaf == CPUID_LNX_4); BUILD_BUG_ON(x86_leaf >= ARRAY_SIZE(reverse_cpuid)); BUILD_BUG_ON(reverse_cpuid...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/reverse_cpuid.h
static __always_inline u32 __feature_leaf(int x86_feature) { return __feature_translate(x86_feature) / 32; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/reverse_cpuid.h
static __always_inline u32 *cpuid_entry_get_reg(struct kvm_cpuid_entry2 *entry, unsigned int x86_feature) { const struct cpuid_reg cpuid = x86_feature_cpuid(x86_feature); return __cpuid_entry_get_reg(entry, cpuid.reg); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/reverse_cpuid.h
static __always_inline void cpuid_entry_set(struct kvm_cpuid_entry2 *entry, unsigned int x86_feature) { u32 *reg = cpuid_entry_get_reg(entry, x86_feature); *reg |= __feature_bit(x86_feature); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/avic.c
static u64 *avic_get_physical_id_entry(struct kvm_vcpu *vcpu, unsigned int index) { u64 *avic_physical_id_table; struct kvm_svm *kvm_svm = to_kvm_svm(vcpu->kvm); if ((avic_mode == AVIC_MODE_X1 && index > AVIC_MAX_PHYSICAL_ID) || (avic_mode == AVIC_MODE_X2 && index > ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/avic.c
static u32 *avic_get_logical_id_entry(struct kvm_vcpu *vcpu, u32 ldr, bool flat) { struct kvm_svm *kvm_svm = to_kvm_svm(vcpu->kvm); int index; u32 *logical_apic_id_table; int dlid = GET_APIC_LOGICAL_ID(ldr); if (!dlid) return NULL; if (flat) { index = ffs(dlid...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/avic.c
static int avic_unaccel_trap_write(struct kvm_vcpu *vcpu) { u32 offset = to_svm(vcpu)->vmcb->control.exit_info_1 & AVIC_UNACCEL_ACCESS_OFFSET_MASK; switch (offset) { case APIC_LDR: if (avic_handle_ldr_update(vcpu)) return 0; break; case APIC_DFR: avic_handle_dfr_update(vcpu); break...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/avic.c
static bool is_avic_unaccelerated_access_trap(u32 offset) { bool ret = false; switch (offset) { case APIC_ID: case APIC_EOI: case APIC_RRR: case APIC_LDR: case APIC_DFR: case APIC_SPIV: case APIC_ESR: case APIC_ICR: case APIC_LVTT: case APIC_LVTTHMR: case APIC_LVTPC: case APIC_LVT0: case...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/avic.c
static void svm_ir_list_del(struct vcpu_svm *svm, struct amd_iommu_pi_data *pi) { unsigned long flags; struct amd_svm_iommu_ir *cur; spin_lock_irqsave(&svm->ir_list_lock, flags); list_for_each_entry(cur, &svm->ir_list, node) { if (cur->data != pi->ir_data) continue; l...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/avic.c
static inline int avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int cpu, bool r) { int ret = 0; unsigned long flags; struct amd_svm_iommu_ir *ir; struct vcpu_svm *svm = to_svm(vcpu); if (!kvm_arch_has_assigned_device(vcpu->kvm)) return 0; spin...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/avic.c
void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); struct vmcb *vmcb = svm->vmcb01.ptr; bool activated = kvm_vcpu_apicv_active(vcpu); if (!enable_apicv) return; if (activated) { avic_apicv_post_state_restore(vcpu); avic_activate_vmcb(svm); } else {...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static bool nested_vmcb_needs_vls_intercept(struct vcpu_svm *svm) { if (!svm->v_vmload_vmsave_enabled) return true; if (!nested_npt_enabled(svm)) return true; if (!(svm->nested.ctl.virt_ext & VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK)) return true; return false; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static bool __nested_vmcb_check_save(struct kvm_vcpu *vcpu, struct vmcb_save_area_cached *save) { if (CC(!(save->efer & EFER_SVME))) return false; if (CC((save->cr0 & X86_CR0_CD) == 0 && (save->cr0 & X86_CR0_NW)) || CC(save->cr0 & ~0xffffffffULL)) return false; ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
void nested_copy_vmcb_control_to_cache(struct vcpu_svm *svm, struct vmcb_control_area *control) { __nested_copy_vmcb_control_to_cache(&svm->vcpu, &svm->nested.ctl, control); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static void __nested_copy_vmcb_save_to_cache(struct vmcb_save_area_cached *to, struct vmcb_save_area *from) { to->efer = from->efer; to->cr0 = from->cr0; to->cr3 = from->cr3; to->cr4 = from->cr4; to->dr6 = from->dr6; to->dr7 = from->dr7; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static void nested_svm_transition_tlb_flush(struct kvm_vcpu *vcpu) { /* * TODO: optimize unconditional TLB flush/MMU sync. A partial list of * things to fix before this can be conditional: * * - Flush TLBs for both L1 and L2 remote TLB flush * - Honor L1's request to flush an ASID on nested VMRUN ...
[ 0, 1 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
void nested_vmcb02_compute_g_pat(struct vcpu_svm *svm) { if (!svm->nested.vmcb02.ptr) return; /* FIXME: merge g_pat from vmcb01 and vmcb12. */ svm->nested.vmcb02.ptr->save.g_pat = svm->vmcb01.ptr->save.g_pat; }
[ 1, 1 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static inline bool is_evtinj_soft(u32 evtinj) { u32 type = evtinj & SVM_EVTINJ_TYPE_MASK; u8 vector = evtinj & SVM_EVTINJ_VEC_MASK; if (!(evtinj & SVM_EVTINJ_VALID)) return false; if (type == SVM_EVTINJ_TYPE_SOFT) return true; return type == SVM_EVTINJ_TYPE_EXEPT && kvm_exception_is_soft(vector); ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
int svm_allocate_nested(struct vcpu_svm *svm) { struct page *vmcb02_page; if (svm->nested.initialized) return 0; vmcb02_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO); if (!vmcb02_page) return -ENOMEM; svm->nested.vmcb02.ptr = page_address(vmcb02_page); svm->nested.vmcb02.pa = __sme_set(page_...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static int nested_svm_exit_handled_msr(struct vcpu_svm *svm) { u32 offset, msr, value; int write, mask; if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT))) return NESTED_EXIT_HOST; msr = svm->vcpu.arch.regs[VCPU_REGS_RCX]; offset = svm_msrpm_offset(msr); write = svm->vmcb->control.exit_i...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static int nested_svm_intercept_ioio(struct vcpu_svm *svm) { unsigned port, size, iopm_len; u16 val, mask; u8 start_bit; u64 gpa; if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_IOIO_PROT))) return NESTED_EXIT_HOST; port = svm->vmcb->control.exit_info_1 >> 16; size = (svm->vmcb->control.exit_...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
static int nested_svm_intercept(struct vcpu_svm *svm) { u32 exit_code = svm->vmcb->control.exit_code; int vmexit = NESTED_EXIT_HOST; switch (exit_code) { case SVM_EXIT_MSR: vmexit = nested_svm_exit_handled_msr(svm); break; case SVM_EXIT_IOIO: vmexit = nested_svm_intercept_ioio(svm); break; ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/nested.c
int nested_svm_exit_handled(struct vcpu_svm *svm) { int vmexit; vmexit = nested_svm_intercept(svm); if (vmexit == NESTED_EXIT_DONE) nested_svm_vmexit(svm); return vmexit; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/pmu.c
static bool amd_pmc_is_enabled(struct kvm_pmc *pmc) { return true; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/pmu.c
static bool amd_is_valid_rdpmc_ecx(struct kvm_vcpu *vcpu, unsigned int idx) { struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); idx &= ~(3u << 30); return idx < pmu->nr_arch_gp_counters; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/pmu.c
static int amd_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) { struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); struct kvm_pmc *pmc; u32 msr = msr_info->index; u64 data = msr_info->data; pmc = get_gp_pmc_amd(pmu, msr, PMU_TYPE_COUNTER); if (pmc) { pmc->counter += data - pmc_read_counter(pmc); ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int sev_misc_cg_try_charge(struct kvm_sev_info *sev) { enum misc_res_type type = sev->es_active ? MISC_CG_RES_SEV_ES : MISC_CG_RES_SEV; return misc_cg_try_charge(type, sev->misc_cg, 1); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int sev_get_asid(struct kvm *kvm) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; return sev->asid; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static void sev_decommission(unsigned int handle) { struct sev_data_decommission decommission; if (!handle) return; decommission.handle = handle; sev_guest_decommission(&decommission, NULL); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int sev_bind_asid(struct kvm *kvm, unsigned int handle, int *error) { struct sev_data_activate activate; int asid = sev_get_asid(kvm); int ret; activate.handle = handle; activate.asid = asid; ret = sev_guest_activate(&activate, error); return ret; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int sev_issue_cmd(struct kvm *kvm, int id, void *data, int *error) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; return __sev_issue_cmd(sev->fd, id, data, error); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static struct page **sev_pin_memory(struct kvm *kvm, unsigned long uaddr, unsigned long ulen, unsigned long *n, int write) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; unsigned long npages, size; int npinned; unsigned long locke...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static void sev_clflush_pages(struct page *pages[], unsigned long npages) { uint8_t *page_virtual; unsigned long i; if (this_cpu_has(X86_FEATURE_SME_COHERENT) || npages == 0 || pages == NULL) return; for (i = 0; i < npages; i++) { page_virtual = kmap_atomic(pages[i]); clflush_cache_range(page_vir...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu, int *error) { struct sev_data_launch_update_vmsa vmsa; struct vcpu_svm *svm = to_svm(vcpu); int ret; ret = sev_es_sync_vmsa(svm); if (ret) return ret; /* * The LAUNCH_UPDATE_VMSA command ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int sev_launch_measure(struct kvm *kvm, struct kvm_sev_cmd *argp) { void __user *measure = (void __user *)(uintptr_t)argp->data; struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct sev_data_launch_measure data; struct kvm_sev_launch_measure params; void __user *p = NULL; void *blob = NULL; ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int __sev_issue_dbg_cmd(struct kvm *kvm, unsigned long src, unsigned long dst, int size, int *error, bool enc) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct sev_data_dbg data; data.reserved = 0; data.handle = sev->handle; ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int __sev_dbg_decrypt(struct kvm *kvm, unsigned long src_paddr, unsigned long dst_paddr, int sz, int *err) { int offset; offset = src_paddr & 15; src_paddr = round_down(src_paddr, 16); sz = round_up(sz + offset, 16); return __sev_issue_dbg_cmd(kvm, src_paddr, dst_paddr, s...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int __sev_dbg_decrypt_user(struct kvm *kvm, unsigned long paddr, void __user *dst_uaddr, unsigned long dst_paddr, int size, int *err) { struct page *tpage = NULL; int ret, offset; if (!IS_ALIGNED(dst_paddr, 16) || !IS_ALIGNED(paddr, 16) |...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int __sev_send_start_query_session_length(struct kvm *kvm, struct kvm_sev_cmd *argp, struct kvm_sev_send_start *params) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct sev_data_send_start data; int ret; memset(&data, 0, sizeof(data)); data.handle =...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static int __sev_send_update_data_query_lengths(struct kvm *kvm, struct kvm_sev_cmd *argp, struct kvm_sev_send_update_data *params) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct sev_data_send_update_data data; int ret; memset(&data, 0, sizeof(data)); dat...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
int sev_mem_enc_register_region(struct kvm *kvm, struct kvm_enc_region *range) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct enc_region *region; int ret = 0; if (!sev_guest(kvm)) return -ENOTTY; if (is_mirroring_enc_context(kvm)) return -EINVAL; if (range->addr > ULONG_MAX || ra...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
void sev_vm_destroy(struct kvm *kvm) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct list_head *head = &sev->regions_list; struct list_head *pos, *q; if (!sev_guest(kvm)) return; WARN_ON(!list_empty(&sev->mirror_vms)); if (is_mirroring_enc_context(kvm)) { struct kvm *owner_kvm = s...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
void __init sev_set_cpu_caps(void) { if (!sev_enabled) kvm_cpu_cap_clear(X86_FEATURE_SEV); if (!sev_es_enabled) kvm_cpu_cap_clear(X86_FEATURE_SEV_ES); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
void sev_hardware_unsetup(void) { if (!sev_enabled) return; sev_flush_asids(1, max_sev_asid); bitmap_free(sev_asid_bitmap); bitmap_free(sev_reclaim_asid_bitmap); misc_cg_set_capacity(MISC_CG_RES_SEV, 0); misc_cg_set_capacity(MISC_CG_RES_SEV_ES, 0); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
void sev_guest_memory_reclaimed(struct kvm *kvm) { if (!sev_guest(kvm)) return; wbinvd_on_all_cpus(); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
void sev_free_vcpu(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm; if (!sev_es_guest(vcpu->kvm)) return; svm = to_svm(vcpu); if (vcpu->arch.guest_state_protected) sev_flush_encrypted_page(vcpu, svm->sev_es.vmsa); __free_page(virt_to_page(svm->sev_es.vmsa)); if (svm->sev_es.ghcb_sa_free) kvf...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static void dump_ghcb(struct vcpu_svm *svm) { struct ghcb *ghcb = svm->sev_es.ghcb; unsigned int nbits; if (!dump_invalid_vmcb) { pr_warn_ratelimited( "set kvm_amd.dump_invalid_vmcb=1 to dump internal KVM state.\n"); return; } nbits = sizeof(ghcb->save.valid_bitmap) * 8; pr_err("GHCB (GPA...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
void sev_es_unmap_ghcb(struct vcpu_svm *svm) { if (!svm->sev_es.ghcb) return; if (svm->sev_es.ghcb_sa_free) { if (svm->sev_es.ghcb_sa_sync) { kvm_write_guest(svm->vcpu.kvm, ghcb_get_sw_scratch(svm->sev_es.ghcb), svm->sev_es.ghcb_sa, svm->sev_es.ghcb_sa_len); svm->sev_es.g...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
static void set_ghcb_msr(struct vcpu_svm *svm, u64 value) { svm->vmcb->control.ghcb_gpa = value; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/sev.c
int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in) { int count; int bytes; int r; if (svm->vmcb->control.exit_info_2 > INT_MAX) return -EINVAL; count = svm->vmcb->control.exit_info_2; if (unlikely(check_mul_overflow(count, size, &bytes))) return -...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/svm.c
void __svm_write_tsc_multiplier(u64 multiplier) { preempt_disable(); if (multiplier == __this_cpu_read(current_tsc_ratio)) goto out; wrmsrl(MSR_AMD64_TSC_RATIO, multiplier); __this_cpu_write(current_tsc_ratio, multiplier); out: preempt_enable(); }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/svm.c
static int svm_cpu_init(int cpu) { struct svm_cpu_data *sd = per_cpu_ptr(&svm_data, cpu); int ret = -ENOMEM; memset(sd, 0, sizeof(struct svm_cpu_data)); sd->save_area = alloc_page(GFP_KERNEL | __GFP_ZERO); if (!sd->save_area) return ret; ret = sev_cpu_init(sd); if (ret) goto free_save_area; ...
[ 1, 0 ]
Linux Kernel
arch/x86/kvm/svm/svm.c
static int direct_access_msr_slot(u32 msr) { u32 i; for (i = 0; direct_access_msrs[i].index != MSR_INVALID; i++) if (direct_access_msrs[i].index == msr) return i; return -ENOENT; }
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/svm.c
static void set_msr_interception_bitmap(struct kvm_vcpu *vcpu, u32 *msrpm, u32 msr, int read, int write) { struct vcpu_svm *svm = to_svm(vcpu); u8 bit_read, bit_write; unsigned long tmp; u32 offset; WARN_ON(!valid_msr_intercept(msr)); /* Enforce non allowed MSRs to ...
[ 0, 0 ]
Linux Kernel
arch/x86/kvm/svm/svm.c
u32 *svm_vcpu_alloc_msrpm(void) { unsigned int order = get_order(MSRPM_SIZE); struct page *pages = alloc_pages(GFP_KERNEL_ACCOUNT, order); u32 *msrpm; if (!pages) return NULL; msrpm = page_address(pages); memset(msrpm, 0xff, PAGE_SIZE * (1 << order)); return msrpm; }
[ 1, 0 ]