summaryrefslogtreecommitdiff
path: root/drivers/crypto/ccp/sev-dev.c
diff options
context:
space:
mode:
authorRijo Thomas <Rijo-john.Thomas@amd.com>2019-12-04 11:49:00 +0530
committerHerbert Xu <herbert@gondor.apana.org.au>2019-12-20 14:58:32 +0800
commit6eb0cc72bcbe9cc5b9ccd41d7226929767e41311 (patch)
treeb43c2be255bab56570afb0a4bc9dfc28ee63363a /drivers/crypto/ccp/sev-dev.c
parentb93566f1bb54e02a1ff1e3b4782073be1886744e (diff)
downloadlinux-sh-6eb0cc72bcbe9cc5b9ccd41d7226929767e41311.tar.gz
crypto: ccp - move SEV vdata to a dedicated data structure
PSP can support both SEV and TEE interface. Therefore, move SEV specific registers to a dedicated data structure. TEE interface specific registers will be added in a later patch. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Jens Wiklander <jens.wiklander@linaro.org> Co-developed-by: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com> Signed-off-by: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com> Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com> Acked-by: Gary R Hook <gary.hook@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp/sev-dev.c')
-rw-r--r--drivers/crypto/ccp/sev-dev.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index fbbe41a58bd8..e467860f797d 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -67,7 +67,7 @@ static void sev_irq_handler(int irq, void *data, unsigned int status)
return;
/* Check if it is SEV command completion: */
- reg = ioread32(sev->io_regs + sev->psp->vdata->cmdresp_reg);
+ reg = ioread32(sev->io_regs + sev->vdata->cmdresp_reg);
if (reg & PSP_CMDRESP_RESP) {
sev->int_rcvd = 1;
wake_up(&sev->int_queue);
@@ -84,7 +84,7 @@ static int sev_wait_cmd_ioc(struct sev_device *sev,
if (!ret)
return -ETIMEDOUT;
- *reg = ioread32(sev->io_regs + sev->psp->vdata->cmdresp_reg);
+ *reg = ioread32(sev->io_regs + sev->vdata->cmdresp_reg);
return 0;
}
@@ -150,15 +150,15 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
print_hex_dump_debug("(in): ", DUMP_PREFIX_OFFSET, 16, 2, data,
sev_cmd_buffer_len(cmd), false);
- iowrite32(phys_lsb, sev->io_regs + psp->vdata->cmdbuff_addr_lo_reg);
- iowrite32(phys_msb, sev->io_regs + psp->vdata->cmdbuff_addr_hi_reg);
+ iowrite32(phys_lsb, sev->io_regs + sev->vdata->cmdbuff_addr_lo_reg);
+ iowrite32(phys_msb, sev->io_regs + sev->vdata->cmdbuff_addr_hi_reg);
sev->int_rcvd = 0;
reg = cmd;
reg <<= SEV_CMDRESP_CMD_SHIFT;
reg |= SEV_CMDRESP_IOC;
- iowrite32(reg, sev->io_regs + psp->vdata->cmdresp_reg);
+ iowrite32(reg, sev->io_regs + sev->vdata->cmdresp_reg);
/* wait for command completion */
ret = sev_wait_cmd_ioc(sev, &reg, psp_timeout);
@@ -958,6 +958,13 @@ int sev_dev_init(struct psp_device *psp)
sev->io_regs = psp->io_regs;
+ sev->vdata = (struct sev_vdata *)psp->vdata->sev;
+ if (!sev->vdata) {
+ ret = -ENODEV;
+ dev_err(dev, "sev: missing driver data\n");
+ goto e_err;
+ }
+
psp_set_sev_irq_handler(psp, sev_irq_handler, sev);
ret = sev_misc_init(sev);