Lines Matching full:vmsa

102  * across the APs VMSA fields (TSC_SCALE and TSC_OFFSET).
962 static int vmgexit_ap_control(u64 event, struct sev_es_save_area *vmsa, u32 apic_id) in vmgexit_ap_control() argument
977 ghcb_set_rax(ghcb, vmsa->sev_features); in vmgexit_ap_control()
984 ghcb_set_sw_exit_info_2(ghcb, __pa(vmsa)); in vmgexit_ap_control()
1030 * If the kernel runs at VMPL0, it can change the VMSA in snp_set_vmsa()
1047 static void snp_cleanup_vmsa(struct sev_es_save_area *vmsa, int apic_id) in snp_cleanup_vmsa() argument
1051 err = snp_set_vmsa(vmsa, NULL, apic_id, false); in snp_cleanup_vmsa()
1053 pr_err("clear VMSA page failed (%u), leaking page\n", err); in snp_cleanup_vmsa()
1055 free_page((unsigned long)vmsa); in snp_cleanup_vmsa()
1157 * the VMSA tag on AP's VMSA pages as they are not being used as
1158 * VMSA page anymore.
1162 struct sev_es_save_area *vmsa; in shutdown_all_aps() local
1172 vmsa = per_cpu(sev_vmsa, cpu); in shutdown_all_aps()
1175 * The BSP or offlined APs do not have guest allocated VMSA in shutdown_all_aps()
1176 * and there is no need to clear the VMSA tag for this page. in shutdown_all_aps()
1178 if (!vmsa) in shutdown_all_aps()
1182 * Cannot clear the VMSA tag for the currently running vCPU. in shutdown_all_aps()
1188 pa = __pa(vmsa); in shutdown_all_aps()
1190 * Mark the VMSA page of the running vCPU as offline in shutdown_all_aps()
1204 * to allow using RMPADJUST to remove the VMSA tag on it's in shutdown_all_aps()
1205 * VMSA page. in shutdown_all_aps()
1207 vmgexit_ap_control(SVM_VMGEXIT_AP_DESTROY, vmsa, apic_id); in shutdown_all_aps()
1208 snp_cleanup_vmsa(vmsa, apic_id); in shutdown_all_aps()
1265 * Allocate VMSA page to work around the SNP erratum where the CPU will in snp_alloc_vmsa_page()
1267 * collides with the RMP entry of VMSA page. The recommended workaround in snp_alloc_vmsa_page()
1286 struct sev_es_save_area *cur_vmsa, *vmsa; in wakeup_cpu_via_vmgexit() local
1322 * A new VMSA is created each time because there is no guarantee that in wakeup_cpu_via_vmgexit()
1323 * the current VMSA is the kernels or that the vCPU is not running. If in wakeup_cpu_via_vmgexit()
1324 * an attempt was done to use the current VMSA with a running vCPU, a in wakeup_cpu_via_vmgexit()
1328 vmsa = (struct sev_es_save_area *)snp_alloc_vmsa_page(cpu); in wakeup_cpu_via_vmgexit()
1329 if (!vmsa) in wakeup_cpu_via_vmgexit()
1340 vmsa->cs.base = sipi_vector << 12; in wakeup_cpu_via_vmgexit()
1341 vmsa->cs.limit = AP_INIT_CS_LIMIT; in wakeup_cpu_via_vmgexit()
1342 vmsa->cs.attrib = INIT_CS_ATTRIBS; in wakeup_cpu_via_vmgexit()
1343 vmsa->cs.selector = sipi_vector << 8; in wakeup_cpu_via_vmgexit()
1346 vmsa->rip = start_ip & 0xfff; in wakeup_cpu_via_vmgexit()
1349 vmsa->ds.limit = AP_INIT_DS_LIMIT; in wakeup_cpu_via_vmgexit()
1350 vmsa->ds.attrib = INIT_DS_ATTRIBS; in wakeup_cpu_via_vmgexit()
1351 vmsa->es = vmsa->ds; in wakeup_cpu_via_vmgexit()
1352 vmsa->fs = vmsa->ds; in wakeup_cpu_via_vmgexit()
1353 vmsa->gs = vmsa->ds; in wakeup_cpu_via_vmgexit()
1354 vmsa->ss = vmsa->ds; in wakeup_cpu_via_vmgexit()
1356 vmsa->gdtr.limit = AP_INIT_GDTR_LIMIT; in wakeup_cpu_via_vmgexit()
1357 vmsa->ldtr.limit = AP_INIT_LDTR_LIMIT; in wakeup_cpu_via_vmgexit()
1358 vmsa->ldtr.attrib = INIT_LDTR_ATTRIBS; in wakeup_cpu_via_vmgexit()
1359 vmsa->idtr.limit = AP_INIT_IDTR_LIMIT; in wakeup_cpu_via_vmgexit()
1360 vmsa->tr.limit = AP_INIT_TR_LIMIT; in wakeup_cpu_via_vmgexit()
1361 vmsa->tr.attrib = INIT_TR_ATTRIBS; in wakeup_cpu_via_vmgexit()
1363 vmsa->cr4 = cr4; in wakeup_cpu_via_vmgexit()
1364 vmsa->cr0 = AP_INIT_CR0_DEFAULT; in wakeup_cpu_via_vmgexit()
1365 vmsa->dr7 = DR7_RESET_VALUE; in wakeup_cpu_via_vmgexit()
1366 vmsa->dr6 = AP_INIT_DR6_DEFAULT; in wakeup_cpu_via_vmgexit()
1367 vmsa->rflags = AP_INIT_RFLAGS_DEFAULT; in wakeup_cpu_via_vmgexit()
1368 vmsa->g_pat = AP_INIT_GPAT_DEFAULT; in wakeup_cpu_via_vmgexit()
1369 vmsa->xcr0 = AP_INIT_XCR0_DEFAULT; in wakeup_cpu_via_vmgexit()
1370 vmsa->mxcsr = AP_INIT_MXCSR_DEFAULT; in wakeup_cpu_via_vmgexit()
1371 vmsa->x87_ftw = AP_INIT_X87_FTW_DEFAULT; in wakeup_cpu_via_vmgexit()
1372 vmsa->x87_fcw = AP_INIT_X87_FCW_DEFAULT; in wakeup_cpu_via_vmgexit()
1375 vmsa->efer = EFER_SVME; in wakeup_cpu_via_vmgexit()
1378 * Set the SNP-specific fields for this VMSA: in wakeup_cpu_via_vmgexit()
1382 vmsa->vmpl = snp_vmpl; in wakeup_cpu_via_vmgexit()
1383 vmsa->sev_features = sev_status >> 2; in wakeup_cpu_via_vmgexit()
1387 vmsa->tsc_scale = snp_tsc_scale; in wakeup_cpu_via_vmgexit()
1388 vmsa->tsc_offset = snp_tsc_offset; in wakeup_cpu_via_vmgexit()
1391 /* Switch the page over to a VMSA page now that it is initialized */ in wakeup_cpu_via_vmgexit()
1392 ret = snp_set_vmsa(vmsa, caa, apic_id, true); in wakeup_cpu_via_vmgexit()
1394 pr_err("set VMSA page failed (%u)\n", ret); in wakeup_cpu_via_vmgexit()
1395 free_page((unsigned long)vmsa); in wakeup_cpu_via_vmgexit()
1401 ret = vmgexit_ap_control(SVM_VMGEXIT_AP_CREATE, vmsa, apic_id); in wakeup_cpu_via_vmgexit()
1403 snp_cleanup_vmsa(vmsa, apic_id); in wakeup_cpu_via_vmgexit()
1404 vmsa = NULL; in wakeup_cpu_via_vmgexit()
1407 /* Free up any previous VMSA page */ in wakeup_cpu_via_vmgexit()
1411 /* Record the current VMSA page */ in wakeup_cpu_via_vmgexit()
1412 per_cpu(sev_vmsa, cpu) = vmsa; in wakeup_cpu_via_vmgexit()