Lines Matching refs:sev

63 	struct sev_device *sev = psp_master->sev_data;  in sev_version_greater_or_equal()  local
65 if (sev->api_major > maj) in sev_version_greater_or_equal()
68 if (sev->api_major == maj && sev->api_minor >= min) in sev_version_greater_or_equal()
76 struct sev_device *sev = data; in sev_irq_handler() local
84 reg = ioread32(sev->io_regs + sev->vdata->cmdresp_reg); in sev_irq_handler()
86 sev->int_rcvd = 1; in sev_irq_handler()
87 wake_up(&sev->int_queue); in sev_irq_handler()
91 static int sev_wait_cmd_ioc(struct sev_device *sev, in sev_wait_cmd_ioc() argument
96 ret = wait_event_timeout(sev->int_queue, in sev_wait_cmd_ioc()
97 sev->int_rcvd, timeout * HZ); in sev_wait_cmd_ioc()
101 *reg = ioread32(sev->io_regs + sev->vdata->cmdresp_reg); in sev_wait_cmd_ioc()
147 struct sev_device *sev; in __sev_do_cmd_locked() local
158 sev = psp->sev_data; in __sev_do_cmd_locked()
170 memcpy(sev->cmd_buf, data, buf_len); in __sev_do_cmd_locked()
173 phys_lsb = data ? lower_32_bits(__psp_pa(sev->cmd_buf)) : 0; in __sev_do_cmd_locked()
174 phys_msb = data ? upper_32_bits(__psp_pa(sev->cmd_buf)) : 0; in __sev_do_cmd_locked()
176 dev_dbg(sev->dev, "sev command id %#x buffer 0x%08x%08x timeout %us\n", in __sev_do_cmd_locked()
182 iowrite32(phys_lsb, sev->io_regs + sev->vdata->cmdbuff_addr_lo_reg); in __sev_do_cmd_locked()
183 iowrite32(phys_msb, sev->io_regs + sev->vdata->cmdbuff_addr_hi_reg); in __sev_do_cmd_locked()
185 sev->int_rcvd = 0; in __sev_do_cmd_locked()
190 iowrite32(reg, sev->io_regs + sev->vdata->cmdresp_reg); in __sev_do_cmd_locked()
193 ret = sev_wait_cmd_ioc(sev, &reg, psp_timeout); in __sev_do_cmd_locked()
198 dev_err(sev->dev, "sev command %#x timed out, disabling PSP\n", cmd); in __sev_do_cmd_locked()
210 dev_dbg(sev->dev, "sev command %#x failed (%#010x)\n", in __sev_do_cmd_locked()
223 memcpy(data, sev->cmd_buf, buf_len); in __sev_do_cmd_locked()
243 struct sev_device *sev; in __sev_platform_init_locked() local
249 sev = psp->sev_data; in __sev_platform_init_locked()
251 if (sev->state == SEV_STATE_INIT) in __sev_platform_init_locked()
273 sev->state = SEV_STATE_INIT; in __sev_platform_init_locked()
281 dev_dbg(sev->dev, "SEV firmware initialized\n"); in __sev_platform_init_locked()
300 struct sev_device *sev = psp_master->sev_data; in __sev_platform_shutdown_locked() local
303 if (sev->state == SEV_STATE_UNINIT) in __sev_platform_shutdown_locked()
310 sev->state = SEV_STATE_UNINIT; in __sev_platform_shutdown_locked()
311 dev_dbg(sev->dev, "SEV firmware shutdown\n"); in __sev_platform_shutdown_locked()
389 struct sev_device *sev = psp_master->sev_data; in sev_ioctl_do_pek_pdh_gen() local
395 if (sev->state == SEV_STATE_UNINIT) { in sev_ioctl_do_pek_pdh_gen()
406 struct sev_device *sev = psp_master->sev_data; in sev_ioctl_do_pek_csr() local
438 if (sev->state == SEV_STATE_UNINIT) { in sev_ioctl_do_pek_csr()
479 struct sev_device *sev = psp_master->sev_data; in sev_get_api_version() local
485 dev_err(sev->dev, in sev_get_api_version()
490 sev->api_major = status.api_major; in sev_get_api_version()
491 sev->api_minor = status.api_minor; in sev_get_api_version()
492 sev->build = status.build; in sev_get_api_version()
493 sev->state = status.state; in sev_get_api_version()
589 struct sev_device *sev = psp_master->sev_data; in sev_ioctl_do_pek_import() local
621 if (sev->state != SEV_STATE_INIT) { in sev_ioctl_do_pek_import()
733 struct sev_device *sev = psp_master->sev_data; in sev_ioctl_do_pdh_export() local
742 if (sev->state != SEV_STATE_INIT) { in sev_ioctl_do_pdh_export()
928 static int sev_misc_init(struct sev_device *sev) in sev_misc_init() argument
930 struct device *dev = sev->dev; in sev_misc_init()
961 init_waitqueue_head(&sev->int_queue); in sev_misc_init()
962 sev->misc = misc_dev; in sev_misc_init()
971 struct sev_device *sev; in sev_dev_init() local
979 sev = devm_kzalloc(dev, sizeof(*sev), GFP_KERNEL); in sev_dev_init()
980 if (!sev) in sev_dev_init()
983 sev->cmd_buf = (void *)devm_get_free_pages(dev, GFP_KERNEL, 0); in sev_dev_init()
984 if (!sev->cmd_buf) in sev_dev_init()
987 psp->sev_data = sev; in sev_dev_init()
989 sev->dev = dev; in sev_dev_init()
990 sev->psp = psp; in sev_dev_init()
992 sev->io_regs = psp->io_regs; in sev_dev_init()
994 sev->vdata = (struct sev_vdata *)psp->vdata->sev; in sev_dev_init()
995 if (!sev->vdata) { in sev_dev_init()
1001 psp_set_sev_irq_handler(psp, sev_irq_handler, sev); in sev_dev_init()
1003 ret = sev_misc_init(sev); in sev_dev_init()
1014 devm_free_pages(dev, (unsigned long)sev->cmd_buf); in sev_dev_init()
1016 devm_kfree(dev, sev); in sev_dev_init()
1025 static void sev_firmware_shutdown(struct sev_device *sev) in sev_firmware_shutdown() argument
1041 struct sev_device *sev = psp->sev_data; in sev_dev_destroy() local
1043 if (!sev) in sev_dev_destroy()
1046 sev_firmware_shutdown(sev); in sev_dev_destroy()
1048 if (sev->misc) in sev_dev_destroy()
1066 struct sev_device *sev = psp_master->sev_data; in sev_pci_init() local
1070 if (!sev) in sev_pci_init()
1079 sev_update_firmware(sev->dev) == 0) in sev_pci_init()
1088 dev_warn(sev->dev, in sev_pci_init()
1102 dev_dbg(sev->dev, "SEV: retrying INIT command"); in sev_pci_init()
1107 dev_err(sev->dev, "SEV: failed to INIT error %#x\n", error); in sev_pci_init()
1111 dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major, in sev_pci_init()
1112 sev->api_minor, sev->build); in sev_pci_init()
1122 struct sev_device *sev = psp_master->sev_data; in sev_pci_exit() local
1124 if (!sev) in sev_pci_exit()
1127 sev_firmware_shutdown(sev); in sev_pci_exit()