Lines Matching refs:sev_common
118 bool (*build_kernel_loader_hashes)(SevCommonState *sev_common,
122 int (*launch_start)(SevCommonState *sev_common);
123 void (*launch_finish)(SevCommonState *sev_common);
124 int (*launch_update_data)(SevCommonState *sev_common, hwaddr gpa, uint8_t *ptr, size_t len);
292 sev_check_state(const SevCommonState *sev_common, SevState state) in sev_check_state() argument
294 assert(sev_common); in sev_check_state()
295 return sev_common->state == state ? true : false; in sev_check_state()
299 sev_set_guest_state(SevCommonState *sev_common, SevState new_state) in sev_set_guest_state() argument
302 assert(sev_common); in sev_set_guest_state()
304 trace_kvm_sev_change_state(SevState_str(sev_common->state), in sev_set_guest_state()
306 sev_common->state = new_state; in sev_set_guest_state()
401 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_get_cbit_position() local
403 return sev_common ? sev_common->cbitpos : 0; in sev_get_cbit_position()
409 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_get_reduced_phys_bits() local
411 return sev_common ? sev_common->reduced_phys_bits : 0; in sev_get_reduced_phys_bits()
417 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_get_info() local
423 info->api_major = sev_common->api_major; in sev_get_info()
424 info->api_minor = sev_common->api_minor; in sev_get_info()
425 info->build_id = sev_common->build_id; in sev_get_info()
426 info->state = sev_common->state; in sev_get_info()
431 object_property_get_uint(OBJECT(sev_common), "policy", NULL); in sev_get_info()
434 info->u.sev.handle = SEV_GUEST(sev_common)->handle; in sev_get_info()
436 (uint32_t)object_property_get_uint(OBJECT(sev_common), in sev_get_info()
577 SevCommonState *sev_common; in sev_get_capabilities() local
589 sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_get_capabilities()
590 if (sev_common) { in sev_get_capabilities()
591 sev_device = object_property_get_str(OBJECT(sev_common), "sev-device", in sev_get_capabilities()
679 SevCommonState *sev_common; in sev_get_attestation_report() local
704 sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_get_attestation_report()
707 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_GET_ATTESTATION_REPORT, in sev_get_attestation_report()
723 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_GET_ATTESTATION_REPORT, in sev_get_attestation_report()
763 sev_snp_launch_start(SevCommonState *sev_common) in sev_snp_launch_start() argument
766 SevSnpGuestState *sev_snp_guest = SEV_SNP_GUEST(sev_common); in sev_snp_launch_start()
776 rc = sev_ioctl(sev_common->sev_fd, KVM_SEV_SNP_LAUNCH_START, in sev_snp_launch_start()
786 sev_set_guest_state(sev_common, SEV_STATE_LAUNCH_UPDATE); in sev_snp_launch_start()
792 sev_launch_start(SevCommonState *sev_common) in sev_launch_start() argument
797 SevGuestState *sev_guest = SEV_GUEST(sev_common); in sev_launch_start()
820 rc = sev_ioctl(sev_common->sev_fd, KVM_SEV_LAUNCH_START, &start, &fw_error); in sev_launch_start()
827 sev_set_guest_state(sev_common, SEV_STATE_LAUNCH_UPDATE); in sev_launch_start()
981 sev_launch_update_data(SevCommonState *sev_common, hwaddr gpa, in sev_launch_update_data() argument
994 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA, in sev_launch_update_data()
1022 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_launch_get_measure() local
1023 SevGuestState *sev_guest = SEV_GUEST(sev_common); in sev_launch_get_measure()
1028 if (!sev_check_state(sev_common, SEV_STATE_LAUNCH_UPDATE)) { in sev_launch_get_measure()
1042 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_LAUNCH_MEASURE, in sev_launch_get_measure()
1054 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_LAUNCH_MEASURE, in sev_launch_get_measure()
1062 sev_set_guest_state(sev_common, SEV_STATE_LAUNCH_SECRET); in sev_launch_get_measure()
1105 sev_launch_finish(SevCommonState *sev_common) in sev_launch_finish() argument
1110 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, in sev_launch_finish()
1118 sev_set_guest_state(sev_common, SEV_STATE_RUNNING); in sev_launch_finish()
1143 sev_snp_launch_update_data(SevCommonState *sev_common, hwaddr gpa, in sev_snp_launch_update_data() argument
1304 sev_snp_launch_finish(SevCommonState *sev_common) in sev_snp_launch_finish() argument
1310 SevSnpGuestState *sev_snp = SEV_SNP_GUEST(sev_common); in sev_snp_launch_finish()
1336 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_SNP_LAUNCH_FINISH, in sev_snp_launch_finish()
1345 sev_set_guest_state(sev_common, SEV_STATE_RUNNING); in sev_snp_launch_finish()
1362 SevCommonState *sev_common = opaque; in sev_vm_state_change() local
1366 if (!sev_check_state(sev_common, SEV_STATE_RUNNING)) { in sev_vm_state_change()
1367 klass->launch_finish(sev_common); in sev_vm_state_change()
1385 SevCommonState *sev_common = SEV_COMMON(cg); in sev_kvm_type() local
1386 SevGuestState *sev_guest = SEV_GUEST(sev_common); in sev_kvm_type()
1389 if (sev_common->kvm_type != -1) { in sev_kvm_type()
1397 sev_common->kvm_type = KVM_X86_DEFAULT_VM; in sev_kvm_type()
1425 sev_common->kvm_type = kvm_type; in sev_kvm_type()
1427 return sev_common->kvm_type; in sev_kvm_type()
1442 SevCommonState *sev_common = SEV_COMMON(cgs); in sev_common_kvm_init() local
1447 sev_common->state = SEV_STATE_UNINIT; in sev_common_kvm_init()
1457 if (host_cbitpos != sev_common->cbitpos) { in sev_common_kvm_init()
1459 __func__, host_cbitpos, sev_common->cbitpos); in sev_common_kvm_init()
1468 if (sev_common->reduced_phys_bits < 1 || in sev_common_kvm_init()
1469 sev_common->reduced_phys_bits > 63) { in sev_common_kvm_init()
1472 __func__, sev_common->reduced_phys_bits); in sev_common_kvm_init()
1476 devname = object_property_get_str(OBJECT(sev_common), "sev-device", NULL); in sev_common_kvm_init()
1477 sev_common->sev_fd = open(devname, O_RDWR); in sev_common_kvm_init()
1478 if (sev_common->sev_fd < 0) { in sev_common_kvm_init()
1486 ret = sev_platform_ioctl(sev_common->sev_fd, SEV_PLATFORM_STATUS, &status, in sev_common_kvm_init()
1494 sev_common->build_id = status.build; in sev_common_kvm_init()
1495 sev_common->api_major = status.api_major; in sev_common_kvm_init()
1496 sev_common->api_minor = status.api_minor; in sev_common_kvm_init()
1516 switch (x86_klass->kvm_type(X86_CONFIDENTIAL_GUEST(sev_common))) { in sev_common_kvm_init()
1520 ret = sev_ioctl(sev_common->sev_fd, cmd, NULL, &fw_error); in sev_common_kvm_init()
1527 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_INIT2, &args, &fw_error); in sev_common_kvm_init()
1542 ret = klass->launch_start(sev_common); in sev_common_kvm_init()
1553 qemu_add_vm_change_state_handler(sev_vm_state_change, sev_common); in sev_common_kvm_init()
1613 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_encrypt_flash() local
1616 if (!sev_common) { in sev_encrypt_flash()
1619 klass = SEV_COMMON_GET_CLASS(sev_common); in sev_encrypt_flash()
1622 if (sev_check_state(sev_common, SEV_STATE_LAUNCH_UPDATE)) { in sev_encrypt_flash()
1625 ret = klass->launch_update_data(sev_common, gpa, ptr, len); in sev_encrypt_flash()
1645 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_inject_launch_secret() local
1647 if (!sev_common) { in sev_inject_launch_secret()
1653 if (!sev_check_state(sev_common, SEV_STATE_LAUNCH_SECRET)) { in sev_inject_launch_secret()
1655 sev_common->state); in sev_inject_launch_secret()
1689 ret = sev_ioctl(sev_common->sev_fd, KVM_SEV_LAUNCH_SECRET, in sev_inject_launch_secret()
1797 SevCommonState *sev_common = SEV_COMMON( in sev_es_set_reset_vector() local
1801 if (!sev_common || !sev_common->reset_data_valid) { in sev_es_set_reset_vector()
1813 cpu_x86_load_seg_cache(env, R_CS, 0xf000, sev_common->reset_cs, 0xffff, in sev_es_set_reset_vector()
1817 env->eip = sev_common->reset_ip; in sev_es_set_reset_vector()
1825 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_es_save_reset_vector() local
1839 sev_common->reset_cs = addr & 0xffff0000; in sev_es_save_reset_vector()
1840 sev_common->reset_ip = addr & 0x0000ffff; in sev_es_save_reset_vector()
1841 sev_common->reset_data_valid = true; in sev_es_save_reset_vector()
1938 static bool sev_snp_build_kernel_loader_hashes(SevCommonState *sev_common, in sev_snp_build_kernel_loader_hashes() argument
1948 SevSnpGuestState *sev_snp_guest = SEV_SNP_GUEST(sev_common); in sev_snp_build_kernel_loader_hashes()
1954 static bool sev_build_kernel_loader_hashes(SevCommonState *sev_common, in sev_build_kernel_loader_hashes() argument
1998 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs); in sev_add_kernel_loader_hashes() local
1999 SevCommonStateClass *klass = SEV_COMMON_GET_CLASS(sev_common); in sev_add_kernel_loader_hashes()
2005 if (!sev_common->kernel_hashes) { in sev_add_kernel_loader_hashes()
2022 return klass->build_kernel_loader_hashes(sev_common, area, ctx, errp); in sev_add_kernel_loader_hashes()
2069 SevCommonState *sev_common = SEV_COMMON(obj); in sev_common_instance_init() local
2071 sev_common->kvm_type = -1; in sev_common_instance_init()
2073 sev_common->sev_device = g_strdup(DEFAULT_SEV_DEVICE); in sev_common_instance_init()
2075 object_property_add_uint32_ptr(obj, "cbitpos", &sev_common->cbitpos, in sev_common_instance_init()
2078 &sev_common->reduced_phys_bits, in sev_common_instance_init()