Commit 6eb0cc72 authored by Rijo Thomas's avatar Rijo Thomas Committed by Herbert Xu

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: default avatarDevaraj Rangasamy <Devaraj.Rangasamy@amd.com>
Signed-off-by: default avatarDevaraj Rangasamy <Devaraj.Rangasamy@amd.com>
Signed-off-by: default avatarRijo Thomas <Rijo-john.Thomas@amd.com>
Acked-by: default avatarGary R Hook <gary.hook@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent b93566f1
...@@ -67,7 +67,7 @@ static void sev_irq_handler(int irq, void *data, unsigned int status) ...@@ -67,7 +67,7 @@ static void sev_irq_handler(int irq, void *data, unsigned int status)
return; return;
/* Check if it is SEV command completion: */ /* 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) { if (reg & PSP_CMDRESP_RESP) {
sev->int_rcvd = 1; sev->int_rcvd = 1;
wake_up(&sev->int_queue); wake_up(&sev->int_queue);
...@@ -84,7 +84,7 @@ static int sev_wait_cmd_ioc(struct sev_device *sev, ...@@ -84,7 +84,7 @@ static int sev_wait_cmd_ioc(struct sev_device *sev,
if (!ret) if (!ret)
return -ETIMEDOUT; return -ETIMEDOUT;
*reg = ioread32(sev->io_regs + sev->psp->vdata->cmdresp_reg); *reg = ioread32(sev->io_regs + sev->vdata->cmdresp_reg);
return 0; return 0;
} }
...@@ -150,15 +150,15 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret) ...@@ -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, print_hex_dump_debug("(in): ", DUMP_PREFIX_OFFSET, 16, 2, data,
sev_cmd_buffer_len(cmd), false); sev_cmd_buffer_len(cmd), false);
iowrite32(phys_lsb, sev->io_regs + psp->vdata->cmdbuff_addr_lo_reg); iowrite32(phys_lsb, sev->io_regs + sev->vdata->cmdbuff_addr_lo_reg);
iowrite32(phys_msb, sev->io_regs + psp->vdata->cmdbuff_addr_hi_reg); iowrite32(phys_msb, sev->io_regs + sev->vdata->cmdbuff_addr_hi_reg);
sev->int_rcvd = 0; sev->int_rcvd = 0;
reg = cmd; reg = cmd;
reg <<= SEV_CMDRESP_CMD_SHIFT; reg <<= SEV_CMDRESP_CMD_SHIFT;
reg |= SEV_CMDRESP_IOC; 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 */ /* wait for command completion */
ret = sev_wait_cmd_ioc(sev, &reg, psp_timeout); ret = sev_wait_cmd_ioc(sev, &reg, psp_timeout);
...@@ -958,6 +958,13 @@ int sev_dev_init(struct psp_device *psp) ...@@ -958,6 +958,13 @@ int sev_dev_init(struct psp_device *psp)
sev->io_regs = psp->io_regs; 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); psp_set_sev_irq_handler(psp, sev_irq_handler, sev);
ret = sev_misc_init(sev); ret = sev_misc_init(sev);
......
...@@ -40,6 +40,8 @@ struct sev_device { ...@@ -40,6 +40,8 @@ struct sev_device {
void __iomem *io_regs; void __iomem *io_regs;
struct sev_vdata *vdata;
int state; int state;
unsigned int int_rcvd; unsigned int int_rcvd;
wait_queue_head_t int_queue; wait_queue_head_t int_queue;
......
...@@ -39,10 +39,14 @@ struct ccp_vdata { ...@@ -39,10 +39,14 @@ struct ccp_vdata {
const unsigned int rsamax; const unsigned int rsamax;
}; };
struct psp_vdata { struct sev_vdata {
const unsigned int cmdresp_reg; const unsigned int cmdresp_reg;
const unsigned int cmdbuff_addr_lo_reg; const unsigned int cmdbuff_addr_lo_reg;
const unsigned int cmdbuff_addr_hi_reg; const unsigned int cmdbuff_addr_hi_reg;
};
struct psp_vdata {
const struct sev_vdata *sev;
const unsigned int feature_reg; const unsigned int feature_reg;
const unsigned int inten_reg; const unsigned int inten_reg;
const unsigned int intsts_reg; const unsigned int intsts_reg;
......
...@@ -262,19 +262,27 @@ static int sp_pci_resume(struct pci_dev *pdev) ...@@ -262,19 +262,27 @@ static int sp_pci_resume(struct pci_dev *pdev)
#endif #endif
#ifdef CONFIG_CRYPTO_DEV_SP_PSP #ifdef CONFIG_CRYPTO_DEV_SP_PSP
static const struct psp_vdata pspv1 = { static const struct sev_vdata sevv1 = {
.cmdresp_reg = 0x10580, .cmdresp_reg = 0x10580,
.cmdbuff_addr_lo_reg = 0x105e0, .cmdbuff_addr_lo_reg = 0x105e0,
.cmdbuff_addr_hi_reg = 0x105e4, .cmdbuff_addr_hi_reg = 0x105e4,
};
static const struct sev_vdata sevv2 = {
.cmdresp_reg = 0x10980,
.cmdbuff_addr_lo_reg = 0x109e0,
.cmdbuff_addr_hi_reg = 0x109e4,
};
static const struct psp_vdata pspv1 = {
.sev = &sevv1,
.feature_reg = 0x105fc, .feature_reg = 0x105fc,
.inten_reg = 0x10610, .inten_reg = 0x10610,
.intsts_reg = 0x10614, .intsts_reg = 0x10614,
}; };
static const struct psp_vdata pspv2 = { static const struct psp_vdata pspv2 = {
.cmdresp_reg = 0x10980, .sev = &sevv2,
.cmdbuff_addr_lo_reg = 0x109e0,
.cmdbuff_addr_hi_reg = 0x109e4,
.feature_reg = 0x109fc, .feature_reg = 0x109fc,
.inten_reg = 0x10690, .inten_reg = 0x10690,
.intsts_reg = 0x10694, .intsts_reg = 0x10694,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment