Lines Matching refs:hc
1831 static int kvm_hv_get_hc_data(struct kvm *kvm, struct kvm_hv_hcall *hc, in kvm_hv_get_hc_data() argument
1842 if (hc->fast) { in kvm_hv_get_hc_data()
1847 if (orig_cnt > 2 * HV_HYPERCALL_MAX_XMM_REGISTERS - hc->consumed_xmm_halves) in kvm_hv_get_hc_data()
1851 j = i + hc->consumed_xmm_halves; in kvm_hv_get_hc_data()
1853 data[i] = sse128_hi(hc->xmm[j / 2]); in kvm_hv_get_hc_data()
1855 data[i] = sse128_lo(hc->xmm[j / 2]); in kvm_hv_get_hc_data()
1860 return kvm_read_guest(kvm, hc->ingpa + hc->data_offset, data, in kvm_hv_get_hc_data()
1864 static u64 kvm_get_sparse_vp_set(struct kvm *kvm, struct kvm_hv_hcall *hc, in kvm_get_sparse_vp_set() argument
1867 if (hc->var_cnt > HV_MAX_SPARSE_VCPU_BANKS) in kvm_get_sparse_vp_set()
1871 return kvm_hv_get_hc_data(kvm, hc, hc->var_cnt, KVM_HV_MAX_SPARSE_VCPU_SET_BITS, in kvm_get_sparse_vp_set()
1875 static int kvm_hv_get_tlb_flush_entries(struct kvm *kvm, struct kvm_hv_hcall *hc, u64 entries[]) in kvm_hv_get_tlb_flush_entries() argument
1877 return kvm_hv_get_hc_data(kvm, hc, hc->rep_cnt, hc->rep_cnt, entries); in kvm_hv_get_tlb_flush_entries()
1950 static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc) in kvm_hv_flush_tlb() argument
1986 if (!hc->fast && is_guest_mode(vcpu)) { in kvm_hv_flush_tlb()
1987 hc->ingpa = translate_nested_gpa(vcpu, hc->ingpa, 0, NULL); in kvm_hv_flush_tlb()
1988 if (unlikely(hc->ingpa == INVALID_GPA)) in kvm_hv_flush_tlb()
1992 if (hc->code == HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST || in kvm_hv_flush_tlb()
1993 hc->code == HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE) { in kvm_hv_flush_tlb()
1994 if (hc->fast) { in kvm_hv_flush_tlb()
1995 flush.address_space = hc->ingpa; in kvm_hv_flush_tlb()
1996 flush.flags = hc->outgpa; in kvm_hv_flush_tlb()
1997 flush.processor_mask = sse128_lo(hc->xmm[0]); in kvm_hv_flush_tlb()
1998 hc->consumed_xmm_halves = 1; in kvm_hv_flush_tlb()
2000 if (unlikely(kvm_read_guest(kvm, hc->ingpa, in kvm_hv_flush_tlb()
2003 hc->data_offset = sizeof(flush); in kvm_hv_flush_tlb()
2023 if (hc->fast) { in kvm_hv_flush_tlb()
2024 flush_ex.address_space = hc->ingpa; in kvm_hv_flush_tlb()
2025 flush_ex.flags = hc->outgpa; in kvm_hv_flush_tlb()
2027 &hc->xmm[0], sizeof(hc->xmm[0])); in kvm_hv_flush_tlb()
2028 hc->consumed_xmm_halves = 2; in kvm_hv_flush_tlb()
2030 if (unlikely(kvm_read_guest(kvm, hc->ingpa, &flush_ex, in kvm_hv_flush_tlb()
2033 hc->data_offset = sizeof(flush_ex); in kvm_hv_flush_tlb()
2045 if (hc->var_cnt != hweight64(valid_bank_mask)) in kvm_hv_flush_tlb()
2049 if (!hc->var_cnt) in kvm_hv_flush_tlb()
2052 if (kvm_get_sparse_vp_set(kvm, hc, sparse_banks)) in kvm_hv_flush_tlb()
2063 if (hc->fast) in kvm_hv_flush_tlb()
2064 hc->consumed_xmm_halves += hc->var_cnt; in kvm_hv_flush_tlb()
2066 hc->data_offset += hc->var_cnt * sizeof(sparse_banks[0]); in kvm_hv_flush_tlb()
2069 if (hc->code == HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE || in kvm_hv_flush_tlb()
2070 hc->code == HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX || in kvm_hv_flush_tlb()
2071 hc->rep_cnt > ARRAY_SIZE(__tlb_flush_entries)) { in kvm_hv_flush_tlb()
2074 if (kvm_hv_get_tlb_flush_entries(kvm, hc, __tlb_flush_entries)) in kvm_hv_flush_tlb()
2087 tlb_flush_entries, hc->rep_cnt); in kvm_hv_flush_tlb()
2100 tlb_flush_entries, hc->rep_cnt); in kvm_hv_flush_tlb()
2133 tlb_flush_entries, hc->rep_cnt); in kvm_hv_flush_tlb()
2142 ((u64)hc->rep_cnt << HV_HYPERCALL_REP_COMP_OFFSET); in kvm_hv_flush_tlb()
2166 static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc) in kvm_hv_send_ipi() argument
2177 if (hc->code == HVCALL_SEND_IPI) { in kvm_hv_send_ipi()
2178 if (!hc->fast) { in kvm_hv_send_ipi()
2179 if (unlikely(kvm_read_guest(kvm, hc->ingpa, &send_ipi, in kvm_hv_send_ipi()
2186 if (unlikely(hc->ingpa >> 32 != 0)) in kvm_hv_send_ipi()
2188 sparse_banks[0] = hc->outgpa; in kvm_hv_send_ipi()
2189 vector = (u32)hc->ingpa; in kvm_hv_send_ipi()
2196 if (!hc->fast) { in kvm_hv_send_ipi()
2197 if (unlikely(kvm_read_guest(kvm, hc->ingpa, &send_ipi_ex, in kvm_hv_send_ipi()
2201 send_ipi_ex.vector = (u32)hc->ingpa; in kvm_hv_send_ipi()
2202 send_ipi_ex.vp_set.format = hc->outgpa; in kvm_hv_send_ipi()
2203 send_ipi_ex.vp_set.valid_bank_mask = sse128_lo(hc->xmm[0]); in kvm_hv_send_ipi()
2214 if (hc->var_cnt != hweight64(valid_bank_mask)) in kvm_hv_send_ipi()
2220 if (!hc->var_cnt) in kvm_hv_send_ipi()
2223 if (!hc->fast) in kvm_hv_send_ipi()
2224 hc->data_offset = offsetof(struct hv_send_ipi_ex, in kvm_hv_send_ipi()
2227 hc->consumed_xmm_halves = 1; in kvm_hv_send_ipi()
2229 if (kvm_get_sparse_vp_set(kvm, hc, sparse_banks)) in kvm_hv_send_ipi()
2353 static u16 kvm_hvcall_signal_event(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc) in kvm_hvcall_signal_event() argument
2358 if (unlikely(!hc->fast)) { in kvm_hvcall_signal_event()
2360 gpa_t gpa = hc->ingpa; in kvm_hvcall_signal_event()
2362 if ((gpa & (__alignof__(hc->ingpa) - 1)) || in kvm_hvcall_signal_event()
2363 offset_in_page(gpa) + sizeof(hc->ingpa) > PAGE_SIZE) in kvm_hvcall_signal_event()
2367 &hc->ingpa, sizeof(hc->ingpa)); in kvm_hvcall_signal_event()
2377 if (hc->ingpa & 0xffff00000000ULL) in kvm_hvcall_signal_event()
2380 if (hc->ingpa & ~KVM_HYPERV_CONN_ID_MASK) in kvm_hvcall_signal_event()
2385 eventfd = idr_find(&hv->conn_to_evt, hc->ingpa); in kvm_hvcall_signal_event()
2394 static bool is_xmm_fast_hypercall(struct kvm_hv_hcall *hc) in is_xmm_fast_hypercall() argument
2396 switch (hc->code) { in is_xmm_fast_hypercall()
2408 static void kvm_hv_hypercall_read_xmm(struct kvm_hv_hcall *hc) in kvm_hv_hypercall_read_xmm() argument
2414 _kvm_read_sse_reg(reg, &hc->xmm[reg]); in kvm_hv_hypercall_read_xmm()
2471 struct kvm_hv_hcall hc; in kvm_hv_hypercall() local
2485 hc.param = kvm_rcx_read(vcpu); in kvm_hv_hypercall()
2486 hc.ingpa = kvm_rdx_read(vcpu); in kvm_hv_hypercall()
2487 hc.outgpa = kvm_r8_read(vcpu); in kvm_hv_hypercall()
2491 hc.param = ((u64)kvm_rdx_read(vcpu) << 32) | in kvm_hv_hypercall()
2493 hc.ingpa = ((u64)kvm_rbx_read(vcpu) << 32) | in kvm_hv_hypercall()
2495 hc.outgpa = ((u64)kvm_rdi_read(vcpu) << 32) | in kvm_hv_hypercall()
2499 hc.code = hc.param & 0xffff; in kvm_hv_hypercall()
2500 hc.var_cnt = (hc.param & HV_HYPERCALL_VARHEAD_MASK) >> HV_HYPERCALL_VARHEAD_OFFSET; in kvm_hv_hypercall()
2501 hc.fast = !!(hc.param & HV_HYPERCALL_FAST_BIT); in kvm_hv_hypercall()
2502 hc.rep_cnt = (hc.param >> HV_HYPERCALL_REP_COMP_OFFSET) & 0xfff; in kvm_hv_hypercall()
2503 hc.rep_idx = (hc.param >> HV_HYPERCALL_REP_START_OFFSET) & 0xfff; in kvm_hv_hypercall()
2504 hc.rep = !!(hc.rep_cnt || hc.rep_idx); in kvm_hv_hypercall()
2506 trace_kvm_hv_hypercall(hc.code, hc.fast, hc.var_cnt, hc.rep_cnt, in kvm_hv_hypercall()
2507 hc.rep_idx, hc.ingpa, hc.outgpa); in kvm_hv_hypercall()
2509 if (unlikely(!hv_check_hypercall_access(hv_vcpu, hc.code))) { in kvm_hv_hypercall()
2514 if (unlikely(hc.param & HV_HYPERCALL_RSVD_MASK)) { in kvm_hv_hypercall()
2519 if (hc.fast && is_xmm_fast_hypercall(&hc)) { in kvm_hv_hypercall()
2527 kvm_hv_hypercall_read_xmm(&hc); in kvm_hv_hypercall()
2530 switch (hc.code) { in kvm_hv_hypercall()
2532 if (unlikely(hc.rep || hc.var_cnt)) { in kvm_hv_hypercall()
2539 if (unlikely(hc.rep || hc.var_cnt)) { in kvm_hv_hypercall()
2543 ret = kvm_hvcall_signal_event(vcpu, &hc); in kvm_hv_hypercall()
2549 if (unlikely(hc.rep || hc.var_cnt || !to_hv_synic(vcpu)->active)) { in kvm_hv_hypercall()
2555 if (unlikely(hc.var_cnt)) { in kvm_hv_hypercall()
2561 if (unlikely(!hc.rep_cnt || hc.rep_idx)) { in kvm_hv_hypercall()
2565 ret = kvm_hv_flush_tlb(vcpu, &hc); in kvm_hv_hypercall()
2568 if (unlikely(hc.var_cnt)) { in kvm_hv_hypercall()
2574 if (unlikely(hc.rep)) { in kvm_hv_hypercall()
2578 ret = kvm_hv_flush_tlb(vcpu, &hc); in kvm_hv_hypercall()
2581 if (unlikely(hc.var_cnt)) { in kvm_hv_hypercall()
2587 if (unlikely(hc.rep)) { in kvm_hv_hypercall()
2591 ret = kvm_hv_send_ipi(vcpu, &hc); in kvm_hv_hypercall()
2595 if (unlikely(hc.fast)) { in kvm_hv_hypercall()
2615 if (unlikely(hc.fast)) { in kvm_hv_hypercall()
2631 vcpu->run->hyperv.u.hcall.input = hc.param; in kvm_hv_hypercall()
2632 vcpu->run->hyperv.u.hcall.params[0] = hc.ingpa; in kvm_hv_hypercall()
2633 vcpu->run->hyperv.u.hcall.params[1] = hc.outgpa; in kvm_hv_hypercall()