• Home
  • Raw
  • Download

Lines Matching +full:set +full:- +full:io +full:- +full:isolation

1 // SPDX-License-Identifier: GPL-2.0
3 * Hyper-V Isolation VM interface with paravisor and hypervisor
15 #include <asm/io.h>
76 return -EFAULT; in hv_ghcb_hypercall()
85 return -EFAULT; in hv_ghcb_hypercall()
88 hv_ghcb->ghcb.protocol_version = GHCB_PROTOCOL_MAX; in hv_ghcb_hypercall()
89 hv_ghcb->ghcb.ghcb_usage = GHCB_USAGE_HYPERV_CALL; in hv_ghcb_hypercall()
91 hv_ghcb->hypercall.outputgpa = (u64)output; in hv_ghcb_hypercall()
92 hv_ghcb->hypercall.hypercallinput.asuint64 = 0; in hv_ghcb_hypercall()
93 hv_ghcb->hypercall.hypercallinput.callcode = control; in hv_ghcb_hypercall()
96 memcpy(hv_ghcb->hypercall.hypercalldata, input, input_size); in hv_ghcb_hypercall()
100 hv_ghcb->ghcb.ghcb_usage = 0xffffffff; in hv_ghcb_hypercall()
101 memset(hv_ghcb->ghcb.save.valid_bitmap, 0, in hv_ghcb_hypercall()
102 sizeof(hv_ghcb->ghcb.save.valid_bitmap)); in hv_ghcb_hypercall()
104 status = hv_ghcb->hypercall.hypercalloutput.callstatus; in hv_ghcb_hypercall()
125 ghcb->protocol_version = hv_ghcb_version; in hv_ghcb_hv_call()
126 ghcb->ghcb_usage = GHCB_DEFAULT_USAGE; in hv_ghcb_hv_call()
134 if (ghcb->save.sw_exit_info_1 & GENMASK_ULL(31, 0)) in hv_ghcb_hv_call()
140 void __noreturn hv_ghcb_terminate(unsigned int set, unsigned int reason) in hv_ghcb_terminate() argument
145 val |= GHCB_SEV_TERM_REASON(set, reason); in hv_ghcb_terminate()
204 ghcb_set_rcx(&hv_ghcb->ghcb, msr); in hv_ghcb_msr_write()
205 ghcb_set_rax(&hv_ghcb->ghcb, lower_32_bits(value)); in hv_ghcb_msr_write()
206 ghcb_set_rdx(&hv_ghcb->ghcb, upper_32_bits(value)); in hv_ghcb_msr_write()
208 if (hv_ghcb_hv_call(&hv_ghcb->ghcb, SVM_EXIT_MSR, 1, 0)) in hv_ghcb_msr_write()
236 ghcb_set_rcx(&hv_ghcb->ghcb, msr); in hv_ghcb_msr_read()
237 if (hv_ghcb_hv_call(&hv_ghcb->ghcb, SVM_EXIT_MSR, 0, 0)) in hv_ghcb_msr_read()
240 *value = (u64)lower_32_bits(hv_ghcb->ghcb.save.rax) in hv_ghcb_msr_read()
241 | ((u64)lower_32_bits(hv_ghcb->ghcb.save.rdx) << 32); in hv_ghcb_msr_read()
302 return -ENOMEM; in hv_snp_boot_ap()
306 vmsa->gdtr.base = gdtr.address; in hv_snp_boot_ap()
307 vmsa->gdtr.limit = gdtr.size; in hv_snp_boot_ap()
309 asm volatile("movl %%es, %%eax;" : "=a" (vmsa->es.selector)); in hv_snp_boot_ap()
310 hv_populate_vmcb_seg(vmsa->es, vmsa->gdtr.base); in hv_snp_boot_ap()
312 asm volatile("movl %%cs, %%eax;" : "=a" (vmsa->cs.selector)); in hv_snp_boot_ap()
313 hv_populate_vmcb_seg(vmsa->cs, vmsa->gdtr.base); in hv_snp_boot_ap()
315 asm volatile("movl %%ss, %%eax;" : "=a" (vmsa->ss.selector)); in hv_snp_boot_ap()
316 hv_populate_vmcb_seg(vmsa->ss, vmsa->gdtr.base); in hv_snp_boot_ap()
318 asm volatile("movl %%ds, %%eax;" : "=a" (vmsa->ds.selector)); in hv_snp_boot_ap()
319 hv_populate_vmcb_seg(vmsa->ds, vmsa->gdtr.base); in hv_snp_boot_ap()
321 vmsa->efer = native_read_msr(MSR_EFER); in hv_snp_boot_ap()
323 asm volatile("movq %%cr4, %%rax;" : "=a" (vmsa->cr4)); in hv_snp_boot_ap()
324 asm volatile("movq %%cr3, %%rax;" : "=a" (vmsa->cr3)); in hv_snp_boot_ap()
325 asm volatile("movq %%cr0, %%rax;" : "=a" (vmsa->cr0)); in hv_snp_boot_ap()
327 vmsa->xcr0 = 1; in hv_snp_boot_ap()
328 vmsa->g_pat = HV_AP_INIT_GPAT_DEFAULT; in hv_snp_boot_ap()
329 vmsa->rip = (u64)secondary_startup_64_no_verify; in hv_snp_boot_ap()
330 vmsa->rsp = (u64)&ap_start_stack[PAGE_SIZE]; in hv_snp_boot_ap()
333 * Set the SNP-specific fields for this VMSA: in hv_snp_boot_ap()
337 vmsa->vmpl = 0; in hv_snp_boot_ap()
338 vmsa->sev_features = sev_status >> 2; in hv_snp_boot_ap()
350 start_vp_input->partition_id = -1; in hv_snp_boot_ap()
351 start_vp_input->vp_index = cpu; in hv_snp_boot_ap()
352 start_vp_input->target_vtl.target_vtl = ms_hyperv.vtl; in hv_snp_boot_ap()
353 *(u64 *)&start_vp_input->vp_context = __pa(vmsa) | 1; in hv_snp_boot_ap()
358 } while (hv_result(ret) == HV_STATUS_TIME_OUT && retry--); in hv_snp_boot_ap()
457 * hv_mark_gpa_visibility - Set pages visible to host via hvcall.
459 * In Isolation VM, all guest memory is encrypted from host and guest
460 * needs to set memory visible to host via hvcall before sharing memory
471 /* no-op if partition isolation is not enabled */ in hv_mark_gpa_visibility()
476 pr_err("Hyper-V: GPA count:%d exceeds supported:%lu\n", count, in hv_mark_gpa_visibility()
478 return -EINVAL; in hv_mark_gpa_visibility()
486 return -EINVAL; in hv_mark_gpa_visibility()
489 input->partition_id = HV_PARTITION_ID_SELF; in hv_mark_gpa_visibility()
490 input->host_visibility = visibility; in hv_mark_gpa_visibility()
491 input->reserved0 = 0; in hv_mark_gpa_visibility()
492 input->reserved1 = 0; in hv_mark_gpa_visibility()
493 memcpy((void *)input->gpa_page_list, pfn, count * sizeof(*pfn)); in hv_mark_gpa_visibility()
502 return -EFAULT; in hv_mark_gpa_visibility()
506 * hv_vtom_set_host_visibility - Set specified memory visible to host.
508 * In Isolation VM, all guest memory is encrypted from host and guest
509 * needs to set memory visible to host via hvcall before sharing memory
530 if (pfn == HV_MAX_MODIFY_GPA_REP_COUNT || i == pagecount - 1) { in hv_vtom_set_host_visibility()
559 * Hyper-V always provides a single IO-APIC in a guest VM. in hv_is_private_mmio()
584 * so SEV initialization is bypassed and sev_status isn't set. in hv_vtom_init()
585 * Set it here to indicate a vTOM VM. in hv_vtom_init()
587 * Note: if CONFIG_AMD_MEM_ENCRYPT is not set, sev_status is in hv_vtom_init()
602 panic("hv_vtom_init: unsupported isolation type %d\n", type); in hv_vtom_init()
606 physical_mask &= ms_hyperv.shared_gpa_boundary - 1; in hv_vtom_init()
613 /* Set WB as the default cache mode. */ in hv_vtom_init()
628 * hv_is_isolation_supported - Check system runs in the Hyper-V
629 * isolation VM.
645 * hv_isolation_type_snp - Check if the system runs in an AMD SEV-SNP based
646 * isolation VM.
655 * hv_isolation_type_tdx - Check if the system runs in an Intel TDX based