Re: [RFC PATCH v2 2/6] crypto: ccp - create a generic psp-dev file
From: Thomas, Rijo-john
Date: Tue Dec 03 2019 - 23:31:05 EST
Hi Gary,
On 03/12/19 9:27 pm, Gary R Hook wrote:
> On 12/2/19 10:39 PM, Rijo Thomas wrote:
>> The PSP (Platform Security Processor) provides support for key management
>> commands in Secure Encrypted Virtualization (SEV) mode, along with
>> software-based Trusted Execution Environment (TEE) to enable third-party
>> Trusted Applications.
>>
>> Therefore, introduce psp-dev.c and psp-dev.h files, which can invoke
>> SEV (or TEE) initialization based on platform feature support.
>>
>> TEE interface support will be introduced in a later patch.
>
>
> This patch does not cleanly apply to the current cryptodev-2.6 tree. Please ensure that you have pulled and rebased, built, and tested just prior to sending out your patches.
Thanks for pointing this out. I shall rebase, test and resend the patchset.
Thanks,
Rijo
>
> grh
>
>>
>> Cc: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
>> Cc: Tom Lendacky <thomas.lendacky@xxxxxxx>
>> Cc: Jens Wiklander <jens.wiklander@xxxxxxxxxx>
>> Co-developed-by: Devaraj Rangasamy <Devaraj.Rangasamy@xxxxxxx>
>> Signed-off-by: Devaraj Rangasamy <Devaraj.Rangasamy@xxxxxxx>
>> Signed-off-by: Rijo Thomas <Rijo-john.Thomas@xxxxxxx>
>> ---
>>  drivers/crypto/ccp/Makefile | 3 +-
>> Â drivers/crypto/ccp/psp-dev.c | 194 ++++++++++++++++++++++++++++++
>> Â drivers/crypto/ccp/psp-dev.h |Â 52 +++++++++
>> Â drivers/crypto/ccp/sev-dev.c | 273 ++++++++++++++++---------------------------
>> Â drivers/crypto/ccp/sev-dev.h |Â 36 +++---
>>  drivers/crypto/ccp/sp-pci.c | 2 +-
>> Â 6 files changed, 367 insertions(+), 193 deletions(-)
>> Â create mode 100644 drivers/crypto/ccp/psp-dev.c
>> Â create mode 100644 drivers/crypto/ccp/psp-dev.h
>>
>> diff --git a/drivers/crypto/ccp/Makefile b/drivers/crypto/ccp/Makefile
>> index 9dafcf2..3b29ea4 100644
>> --- a/drivers/crypto/ccp/Makefile
>> +++ b/drivers/crypto/ccp/Makefile
>> @@ -8,7 +8,8 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \
>> ÂÂÂÂÂÂÂÂÂ ccp-dmaengine.o
>> Â ccp-$(CONFIG_CRYPTO_DEV_CCP_DEBUGFS) += ccp-debugfs.o
>> Â ccp-$(CONFIG_PCI) += sp-pci.o
>> -ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += sev-dev.o
>> +ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ sev-dev.o
>> Â Â obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
>> Â ccp-crypto-objs := ccp-crypto-main.o \
>> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
>> new file mode 100644
>> index 0000000..2cd7a5e
>> --- /dev/null
>> +++ b/drivers/crypto/ccp/psp-dev.c
>> @@ -0,0 +1,194 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * AMD Platform Security Processor (PSP) interface
>> + *
>> + * Copyright (C) 2016,2019 Advanced Micro Devices, Inc.
>> + *
>> + * Author: Brijesh Singh <brijesh.singh@xxxxxxx>
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/irqreturn.h>
>> +
>> +#include "sp-dev.h"
>> +#include "psp-dev.h"
>> +#include "sev-dev.h"
>> +
>> +struct psp_device *psp_master;
>> +
>> +static struct psp_device *psp_alloc_struct(struct sp_device *sp)
>> +{
>> +ÂÂÂ struct device *dev = sp->dev;
>> +ÂÂÂ struct psp_device *psp;
>> +
>> +ÂÂÂ psp = devm_kzalloc(dev, sizeof(*psp), GFP_KERNEL);
>> +ÂÂÂ if (!psp)
>> +ÂÂÂÂÂÂÂ return NULL;
>> +
>> +ÂÂÂ psp->dev = dev;
>> +ÂÂÂ psp->sp = sp;
>> +
>> +ÂÂÂ snprintf(psp->name, sizeof(psp->name), "psp-%u", sp->ord);
>> +
>> +ÂÂÂ return psp;
>> +}
>> +
>> +static irqreturn_t psp_irq_handler(int irq, void *data)
>> +{
>> +ÂÂÂ struct psp_device *psp = data;
>> +ÂÂÂ unsigned int status;
>> +
>> +ÂÂÂ /* Read the interrupt status: */
>> +ÂÂÂ status = ioread32(psp->io_regs + psp->vdata->intsts_reg);
>> +
>> +ÂÂÂ /* invoke subdevice interrupt handlers */
>> +ÂÂÂ if (status) {
>> +ÂÂÂÂÂÂÂ if (psp->sev_irq_handler)
>> +ÂÂÂÂÂÂÂÂÂÂÂ psp->sev_irq_handler(irq, psp->sev_irq_data, status);
>> +ÂÂÂ }
>> +
>> +ÂÂÂ /* Clear the interrupt status by writing the same value we read. */
>> +ÂÂÂ iowrite32(status, psp->io_regs + psp->vdata->intsts_reg);
>> +
>> +ÂÂÂ return IRQ_HANDLED;
>> +}
>> +
>> +static int psp_check_sev_support(struct psp_device *psp)
>> +{
>> +ÂÂÂ unsigned int val = ioread32(psp->io_regs + psp->vdata->feature_reg);
>> +
>> +ÂÂÂ /*
>> + * Check for a access to the registers. If this read returns
>> +ÂÂÂÂ * 0xffffffff, it's likely that the system is running a broken
>> +ÂÂÂÂ * BIOS which disallows access to the device. Stop here and
>> +ÂÂÂÂ * fail the PSP initialization (but not the load, as the CCP
>> +ÂÂÂÂ * could get properly initialized).
>> +ÂÂÂÂ */
>> +ÂÂÂ if (val == 0xffffffff) {
>> +ÂÂÂÂÂÂÂ dev_notice(psp->dev, "psp: unable to access the device: you might be running a broken BIOS.\n");
>> +ÂÂÂÂÂÂÂ return -ENODEV;
>> +ÂÂÂ }
>> +
>> +ÂÂÂ if (!(val & 1)) {
>> +ÂÂÂÂÂÂÂ /* Device does not support the SEV feature */
>> +ÂÂÂÂÂÂÂ dev_dbg(psp->dev, "psp does not support SEV\n");
>> +ÂÂÂÂÂÂÂ return -ENODEV;
>> +ÂÂÂ }
>> +
>> +ÂÂÂ return 0;
>> +}
>> +
>> +int psp_dev_init(struct sp_device *sp)
>> +{
>> +ÂÂÂ struct device *dev = sp->dev;
>> +ÂÂÂ struct psp_device *psp;
>> +ÂÂÂ int ret;
>> +
>> +ÂÂÂ ret = -ENOMEM;
>> +ÂÂÂ psp = psp_alloc_struct(sp);
>> +ÂÂÂ if (!psp)
>> +ÂÂÂÂÂÂÂ goto e_err;
>> +
>> +ÂÂÂ sp->psp_data = psp;
>> +
>> +ÂÂÂ psp->vdata = (struct psp_vdata *)sp->dev_vdata->psp_vdata;
>> +ÂÂÂ if (!psp->vdata) {
>> +ÂÂÂÂÂÂÂ ret = -ENODEV;
>> +ÂÂÂÂÂÂÂ dev_err(dev, "missing driver data\n");
>> +ÂÂÂÂÂÂÂ goto e_err;
>> +ÂÂÂ }
>> +
>> +ÂÂÂ psp->io_regs = sp->io_map;
>> +
>> +ÂÂÂ ret = psp_check_sev_support(psp);
>> +ÂÂÂ if (ret)
>> +ÂÂÂÂÂÂÂ goto e_disable;
>> +
>> +ÂÂÂ /* Disable and clear interrupts until ready */
>> +ÂÂÂ iowrite32(0, psp->io_regs + psp->vdata->inten_reg);
>> +ÂÂÂ iowrite32(-1, psp->io_regs + psp->vdata->intsts_reg);
>> +
>> +ÂÂÂ /* Request an irq */
>> +ÂÂÂ ret = sp_request_psp_irq(psp->sp, psp_irq_handler, psp->name, psp);
>> +ÂÂÂ if (ret) {
>> +ÂÂÂÂÂÂÂ dev_err(dev, "psp: unable to allocate an IRQ\n");
>> +ÂÂÂÂÂÂÂ goto e_err;
>> +ÂÂÂ }
>> +
>> +ÂÂÂ ret = sev_dev_init(psp);
>> +ÂÂÂ if (ret)
>> +ÂÂÂÂÂÂÂ goto e_irq;
>> +
>> +ÂÂÂ if (sp->set_psp_master_device)
>> +ÂÂÂÂÂÂÂ sp->set_psp_master_device(sp);
>> +
>> +ÂÂÂ /* Enable interrupt */
>> +ÂÂÂ iowrite32(-1, psp->io_regs + psp->vdata->inten_reg);
>> +
>> +ÂÂÂ dev_notice(dev, "psp enabled\n");
>> +
>> +ÂÂÂ return 0;
>> +
>> +e_irq:
>> +ÂÂÂ sp_free_psp_irq(psp->sp, psp);
>> +e_err:
>> +ÂÂÂ sp->psp_data = NULL;
>> +
>> +ÂÂÂ dev_notice(dev, "psp initialization failed\n");
>> +
>> +ÂÂÂ return ret;
>> +
>> +e_disable:
>> +ÂÂÂ sp->psp_data = NULL;
>> +
>> +ÂÂÂ return ret;
>> +}
>> +
>> +void psp_dev_destroy(struct sp_device *sp)
>> +{
>> +ÂÂÂ struct psp_device *psp = sp->psp_data;
>> +
>> +ÂÂÂ if (!psp)
>> +ÂÂÂÂÂÂÂ return;
>> +
>> +ÂÂÂ sev_dev_destroy(psp);
>> +
>> +ÂÂÂ sp_free_psp_irq(sp, psp);
>> +}
>> +
>> +void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ void *data)
>> +{
>> +ÂÂÂ psp->sev_irq_data = data;
>> +ÂÂÂ psp->sev_irq_handler = handler;
>> +}
>> +
>> +void psp_clear_sev_irq_handler(struct psp_device *psp)
>> +{
>> +ÂÂÂ psp_set_sev_irq_handler(psp, NULL, NULL);
>> +}
>> +
>> +struct psp_device *psp_get_master_device(void)
>> +{
>> +ÂÂÂ struct sp_device *sp = sp_get_psp_master_device();
>> +
>> +ÂÂÂ return sp ? sp->psp_data : NULL;
>> +}
>> +
>> +void psp_pci_init(void)
>> +{
>> +ÂÂÂ psp_master = psp_get_master_device();
>> +
>> +ÂÂÂ if (!psp_master)
>> +ÂÂÂÂÂÂÂ return;
>> +
>> +ÂÂÂ sev_pci_init();
>> +}
>> +
>> +void psp_pci_exit(void)
>> +{
>> +ÂÂÂ if (!psp_master)
>> +ÂÂÂÂÂÂÂ return;
>> +
>> +ÂÂÂ sev_pci_exit();
>> +}
>> diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h
>> new file mode 100644
>> index 0000000..7c014ac
>> --- /dev/null
>> +++ b/drivers/crypto/ccp/psp-dev.h
>> @@ -0,0 +1,52 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +/*
>> + * AMD Platform Security Processor (PSP) interface driver
>> + *
>> + * Copyright (C) 2017-2019 Advanced Micro Devices, Inc.
>> + *
>> + * Author: Brijesh Singh <brijesh.singh@xxxxxxx>
>> + */
>> +
>> +#ifndef __PSP_DEV_H__
>> +#define __PSP_DEV_H__
>> +
>> +#include <linux/device.h>
>> +#include <linux/list.h>
>> +#include <linux/bits.h>
>> +#include <linux/interrupt.h>
>> +
>> +#include "sp-dev.h"
>> +
>> +#define PSP_CMDRESP_RESPÂÂÂÂÂÂÂ BIT(31)
>> +#define PSP_CMDRESP_ERR_MASKÂÂÂÂÂÂÂ 0xffff
>> +
>> +#define MAX_PSP_NAME_LENÂÂÂÂÂÂÂ 16
>> +
>> +extern struct psp_device *psp_master;
>> +
>> +typedef void (*psp_irq_handler_t)(int, void *, unsigned int);
>> +
>> +struct psp_device {
>> +ÂÂÂ struct list_head entry;
>> +
>> +ÂÂÂ struct psp_vdata *vdata;
>> +ÂÂÂ char name[MAX_PSP_NAME_LEN];
>> +
>> +ÂÂÂ struct device *dev;
>> +ÂÂÂ struct sp_device *sp;
>> +
>> +ÂÂÂ void __iomem *io_regs;
>> +
>> +ÂÂÂ psp_irq_handler_t sev_irq_handler;
>> +ÂÂÂ void *sev_irq_data;
>> +
>> +ÂÂÂ void *sev_data;
>> +};
>> +
>> +void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ void *data);
>> +void psp_clear_sev_irq_handler(struct psp_device *psp);
>> +
>> +struct psp_device *psp_get_master_device(void);
>> +
>> +#endif /* __PSP_DEV_H */
>> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
>> index ba9f555..ec595e6 100644
>> --- a/drivers/crypto/ccp/sev-dev.c
>> +++ b/drivers/crypto/ccp/sev-dev.c
>> @@ -21,7 +21,7 @@
>> Â #include <linux/ccp.h>
>> Â #include <linux/firmware.h>
>> Â -#include "sp-dev.h"
>> +#include "psp-dev.h"
>> Â #include "sev-dev.h"
>> Â Â #define DEVICE_NAMEÂÂÂÂÂÂÂ "sev"
>> @@ -30,7 +30,6 @@
>> Â Â static DEFINE_MUTEX(sev_cmd_mutex);
>> Â static struct sev_misc_dev *misc_dev;
>> -static struct psp_device *psp_master;
>> Â Â static int psp_cmd_timeout = 100;
>> Â module_param(psp_cmd_timeout, int, 0644);
>> @@ -45,68 +44,45 @@
>> Â Â static inline bool sev_version_greater_or_equal(u8 maj, u8 min)
>> Â {
>> -ÂÂÂ if (psp_master->api_major > maj)
>> -ÂÂÂÂÂÂÂ return true;
>> -ÂÂÂ if (psp_master->api_major == maj && psp_master->api_minor >= min)
>> -ÂÂÂÂÂÂÂ return true;
>> -ÂÂÂ return false;
>> -}
>> -
>> -static struct psp_device *psp_alloc_struct(struct sp_device *sp)
>> -{
>> -ÂÂÂ struct device *dev = sp->dev;
>> -ÂÂÂ struct psp_device *psp;
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> Â -ÂÂÂ psp = devm_kzalloc(dev, sizeof(*psp), GFP_KERNEL);
>> -ÂÂÂ if (!psp)
>> -ÂÂÂÂÂÂÂ return NULL;
>> -
>> -ÂÂÂ psp->dev = dev;
>> -ÂÂÂ psp->sp = sp;
>> +ÂÂÂ if (sev->api_major > maj)
>> +ÂÂÂÂÂÂÂ return true;
>> Â -ÂÂÂ snprintf(psp->name, sizeof(psp->name), "psp-%u", sp->ord);
>> +ÂÂÂ if (sev->api_major == maj && sev->api_minor >= min)
>> +ÂÂÂÂÂÂÂ return true;
>> Â -ÂÂÂ return psp;
>> +ÂÂÂ return false;
>> Â }
>> Â -static irqreturn_t psp_irq_handler(int irq, void *data)
>> +static void sev_irq_handler(int irq, void *data, unsigned int status)
>> Â {
>> -ÂÂÂ struct psp_device *psp = data;
>> -ÂÂÂ unsigned int status;
>> +ÂÂÂ struct sev_device *sev = data;
>> ÂÂÂÂÂ int reg;
>> Â -ÂÂÂ /* Read the interrupt status: */
>> -ÂÂÂ status = ioread32(psp->io_regs + psp->vdata->intsts_reg);
>> -
>> ÂÂÂÂÂ /* Check if it is command completion: */
>> -ÂÂÂ if (!(status & PSP_CMD_COMPLETE))
>> -ÂÂÂÂÂÂÂ goto done;
>> +ÂÂÂ if (!(status & SEV_CMD_COMPLETE))
>> +ÂÂÂÂÂÂÂ return;
>> Â ÂÂÂÂÂ /* Check if it is SEV command completion: */
>> -ÂÂÂ reg = ioread32(psp->io_regs + psp->vdata->cmdresp_reg);
>> +ÂÂÂ reg = ioread32(sev->io_regs + sev->psp->vdata->cmdresp_reg);
>> ÂÂÂÂÂ if (reg & PSP_CMDRESP_RESP) {
>> -ÂÂÂÂÂÂÂ psp->sev_int_rcvd = 1;
>> -ÂÂÂÂÂÂÂ wake_up(&psp->sev_int_queue);
>> +ÂÂÂÂÂÂÂ sev->int_rcvd = 1;
>> +ÂÂÂÂÂÂÂ wake_up(&sev->int_queue);
>> ÂÂÂÂÂ }
>> -
>> -done:
>> -ÂÂÂ /* Clear the interrupt status by writing the same value we read. */
>> -ÂÂÂ iowrite32(status, psp->io_regs + psp->vdata->intsts_reg);
>> -
>> -ÂÂÂ return IRQ_HANDLED;
>> Â }
>> Â -static int sev_wait_cmd_ioc(struct psp_device *psp,
>> +static int sev_wait_cmd_ioc(struct sev_device *sev,
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ unsigned int *reg, unsigned int timeout)
>> Â {
>> ÂÂÂÂÂ int ret;
>> Â -ÂÂÂ ret = wait_event_timeout(psp->sev_int_queue,
>> -ÂÂÂÂÂÂÂÂÂÂÂ psp->sev_int_rcvd, timeout * HZ);
>> +ÂÂÂ ret = wait_event_timeout(sev->int_queue,
>> +ÂÂÂÂÂÂÂÂÂÂÂ sev->int_rcvd, timeout * HZ);
>> ÂÂÂÂÂ if (!ret)
>> ÂÂÂÂÂÂÂÂÂ return -ETIMEDOUT;
>> Â -ÂÂÂ *reg = ioread32(psp->io_regs + psp->vdata->cmdresp_reg);
>> +ÂÂÂ *reg = ioread32(sev->io_regs + sev->psp->vdata->cmdresp_reg);
>> Â ÂÂÂÂÂ return 0;
>> Â }
>> @@ -150,42 +126,45 @@ static int sev_cmd_buffer_len(int cmd)
>> Â static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
>> Â {
>> ÂÂÂÂÂ struct psp_device *psp = psp_master;
>> +ÂÂÂ struct sev_device *sev;
>> ÂÂÂÂÂ unsigned int phys_lsb, phys_msb;
>> ÂÂÂÂÂ unsigned int reg, ret = 0;
>> Â -ÂÂÂ if (!psp)
>> +ÂÂÂ if (!psp || !psp->sev_data)
>> ÂÂÂÂÂÂÂÂÂ return -ENODEV;
>> Â ÂÂÂÂÂ if (psp_dead)
>> ÂÂÂÂÂÂÂÂÂ return -EBUSY;
>> Â +ÂÂÂ sev = psp->sev_data;
>> +
>> ÂÂÂÂÂ /* Get the physical address of the command buffer */
>> ÂÂÂÂÂ phys_lsb = data ? lower_32_bits(__psp_pa(data)) : 0;
>> ÂÂÂÂÂ phys_msb = data ? upper_32_bits(__psp_pa(data)) : 0;
>> Â -ÂÂÂ dev_dbg(psp->dev, "sev command id %#x buffer 0x%08x%08x timeout %us\n",
>> +ÂÂÂ dev_dbg(sev->dev, "sev command id %#x buffer 0x%08x%08x timeout %us\n",
>> ÂÂÂÂÂÂÂÂÂ cmd, phys_msb, phys_lsb, psp_timeout);
>> Â ÂÂÂÂÂ print_hex_dump_debug("(in):Â ", DUMP_PREFIX_OFFSET, 16, 2, data,
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ sev_cmd_buffer_len(cmd), false);
>> Â -ÂÂÂ iowrite32(phys_lsb, psp->io_regs + psp->vdata->cmdbuff_addr_lo_reg);
>> -ÂÂÂ iowrite32(phys_msb, psp->io_regs + psp->vdata->cmdbuff_addr_hi_reg);
>> +ÂÂÂ iowrite32(phys_lsb, sev->io_regs + psp->vdata->cmdbuff_addr_lo_reg);
>> +ÂÂÂ iowrite32(phys_msb, sev->io_regs + psp->vdata->cmdbuff_addr_hi_reg);
>> Â -ÂÂÂ psp->sev_int_rcvd = 0;
>> +ÂÂÂ sev->int_rcvd = 0;
>> Â ÂÂÂÂÂ reg = cmd;
>> -ÂÂÂ reg <<= PSP_CMDRESP_CMD_SHIFT;
>> -ÂÂÂ reg |= PSP_CMDRESP_IOC;
>> -ÂÂÂ iowrite32(reg, psp->io_regs + psp->vdata->cmdresp_reg);
>> +ÂÂÂ reg <<= SEV_CMDRESP_CMD_SHIFT;
>> +ÂÂÂ reg |= SEV_CMDRESP_IOC;
>> +ÂÂÂ iowrite32(reg, sev->io_regs + psp->vdata->cmdresp_reg);
>> Â ÂÂÂÂÂ /* wait for command completion */
>> -ÂÂÂ ret = sev_wait_cmd_ioc(psp, ®, psp_timeout);
>> +ÂÂÂ ret = sev_wait_cmd_ioc(sev, ®, psp_timeout);
>> ÂÂÂÂÂ if (ret) {
>> ÂÂÂÂÂÂÂÂÂ if (psp_ret)
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ *psp_ret = 0;
>> Â -ÂÂÂÂÂÂÂ dev_err(psp->dev, "sev command %#x timed out, disabling PSP \n", cmd);
>> +ÂÂÂÂÂÂÂ dev_err(sev->dev, "sev command %#x timed out, disabling PSP\n", cmd);
>> ÂÂÂÂÂÂÂÂÂ psp_dead = true;
>> Â ÂÂÂÂÂÂÂÂÂ return ret;
>> @@ -197,7 +176,7 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
>> ÂÂÂÂÂÂÂÂÂ *psp_ret = reg & PSP_CMDRESP_ERR_MASK;
>> Â ÂÂÂÂÂ if (reg & PSP_CMDRESP_ERR_MASK) {
>> -ÂÂÂÂÂÂÂ dev_dbg(psp->dev, "sev command %#x failed (%#010x)\n",
>> +ÂÂÂÂÂÂÂ dev_dbg(sev->dev, "sev command %#x failed (%#010x)\n",
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ cmd, reg & PSP_CMDRESP_ERR_MASK);
>> ÂÂÂÂÂÂÂÂÂ ret = -EIO;
>> ÂÂÂÂÂ }
>> @@ -222,20 +201,23 @@ static int sev_do_cmd(int cmd, void *data, int *psp_ret)
>> Â static int __sev_platform_init_locked(int *error)
>> Â {
>> ÂÂÂÂÂ struct psp_device *psp = psp_master;
>> +ÂÂÂ struct sev_device *sev;
>> ÂÂÂÂÂ int rc = 0;
>> Â -ÂÂÂ if (!psp)
>> +ÂÂÂ if (!psp || !psp->sev_data)
>> ÂÂÂÂÂÂÂÂÂ return -ENODEV;
>> Â -ÂÂÂ if (psp->sev_state == SEV_STATE_INIT)
>> +ÂÂÂ sev = psp->sev_data;
>> +
>> +ÂÂÂ if (sev->state == SEV_STATE_INIT)
>> ÂÂÂÂÂÂÂÂÂ return 0;
>> Â -ÂÂÂ rc = __sev_do_cmd_locked(SEV_CMD_INIT, &psp->init_cmd_buf, error);
>> +ÂÂÂ rc = __sev_do_cmd_locked(SEV_CMD_INIT, &sev->init_cmd_buf, error);
>> ÂÂÂÂÂ if (rc)
>> ÂÂÂÂÂÂÂÂÂ return rc;
>> Â -ÂÂÂ psp->sev_state = SEV_STATE_INIT;
>> -ÂÂÂ dev_dbg(psp->dev, "SEV firmware initialized\n");
>> +ÂÂÂ sev->state = SEV_STATE_INIT;
>> +ÂÂÂ dev_dbg(sev->dev, "SEV firmware initialized\n");
>> Â ÂÂÂÂÂ return rc;
>> Â }
>> @@ -254,14 +236,15 @@ int sev_platform_init(int *error)
>> Â Â static int __sev_platform_shutdown_locked(int *error)
>> Â {
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ int ret;
>> Â ÂÂÂÂÂ ret = __sev_do_cmd_locked(SEV_CMD_SHUTDOWN, NULL, error);
>> ÂÂÂÂÂ if (ret)
>> ÂÂÂÂÂÂÂÂÂ return ret;
>> Â -ÂÂÂ psp_master->sev_state = SEV_STATE_UNINIT;
>> -ÂÂÂ dev_dbg(psp_master->dev, "SEV firmware shutdown\n");
>> +ÂÂÂ sev->state = SEV_STATE_UNINIT;
>> +ÂÂÂ dev_dbg(sev->dev, "SEV firmware shutdown\n");
>> Â ÂÂÂÂÂ return ret;
>> Â }
>> @@ -279,14 +262,15 @@ static int sev_platform_shutdown(int *error)
>> Â Â static int sev_get_platform_state(int *state, int *error)
>> Â {
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ int rc;
>> Â ÂÂÂÂÂ rc = __sev_do_cmd_locked(SEV_CMD_PLATFORM_STATUS,
>> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &psp_master->status_cmd_buf, error);
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &sev->status_cmd_buf, error);
>> ÂÂÂÂÂ if (rc)
>> ÂÂÂÂÂÂÂÂÂ return rc;
>> Â -ÂÂÂ *state = psp_master->status_cmd_buf.state;
>> +ÂÂÂ *state = sev->status_cmd_buf.state;
>> ÂÂÂÂÂ return rc;
>> Â }
>> Â @@ -321,7 +305,8 @@ static int sev_ioctl_do_reset(struct sev_issue_cmd *argp)
>> Â Â static int sev_ioctl_do_platform_status(struct sev_issue_cmd *argp)
>> Â {
>> -ÂÂÂ struct sev_user_data_status *data = &psp_master->status_cmd_buf;
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> +ÂÂÂ struct sev_user_data_status *data = &sev->status_cmd_buf;
>> ÂÂÂÂÂ int ret;
>> Â ÂÂÂÂÂ ret = __sev_do_cmd_locked(SEV_CMD_PLATFORM_STATUS, data, &argp->error);
>> @@ -336,9 +321,10 @@ static int sev_ioctl_do_platform_status(struct sev_issue_cmd *argp)
>> Â Â static int sev_ioctl_do_pek_pdh_gen(int cmd, struct sev_issue_cmd *argp)
>> Â {
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ int rc;
>> Â -ÂÂÂ if (psp_master->sev_state == SEV_STATE_UNINIT) {
>> +ÂÂÂ if (sev->state == SEV_STATE_UNINIT) {
>> ÂÂÂÂÂÂÂÂÂ rc = __sev_platform_init_locked(&argp->error);
>> ÂÂÂÂÂÂÂÂÂ if (rc)
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ return rc;
>> @@ -349,6 +335,7 @@ static int sev_ioctl_do_pek_pdh_gen(int cmd, struct sev_issue_cmd *argp)
>> Â Â static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp)
>> Â {
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ struct sev_user_data_pek_csr input;
>> ÂÂÂÂÂ struct sev_data_pek_csr *data;
>> ÂÂÂÂÂ void *blob = NULL;
>> @@ -382,7 +369,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp)
>> ÂÂÂÂÂ data->len = input.length;
>> Â Â cmd:
>> -ÂÂÂ if (psp_master->sev_state == SEV_STATE_UNINIT) {
>> +ÂÂÂ if (sev->state == SEV_STATE_UNINIT) {
>> ÂÂÂÂÂÂÂÂÂ ret = __sev_platform_init_locked(&argp->error);
>> ÂÂÂÂÂÂÂÂÂ if (ret)
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ goto e_free_blob;
>> @@ -425,21 +412,22 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len)
>> Â Â static int sev_get_api_version(void)
>> Â {
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ struct sev_user_data_status *status;
>> ÂÂÂÂÂ int error = 0, ret;
>> Â -ÂÂÂ status = &psp_master->status_cmd_buf;
>> +ÂÂÂ status = &sev->status_cmd_buf;
>> ÂÂÂÂÂ ret = sev_platform_status(status, &error);
>> ÂÂÂÂÂ if (ret) {
>> -ÂÂÂÂÂÂÂ dev_err(psp_master->dev,
>> +ÂÂÂÂÂÂÂ dev_err(sev->dev,
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ "SEV: failed to get status. Error: %#x\n", error);
>> ÂÂÂÂÂÂÂÂÂ return 1;
>> ÂÂÂÂÂ }
>> Â -ÂÂÂ psp_master->api_major = status->api_major;
>> -ÂÂÂ psp_master->api_minor = status->api_minor;
>> -ÂÂÂ psp_master->build = status->build;
>> -ÂÂÂ psp_master->sev_state = status->state;
>> +ÂÂÂ sev->api_major = status->api_major;
>> +ÂÂÂ sev->api_minor = status->api_minor;
>> +ÂÂÂ sev->build = status->build;
>> +ÂÂÂ sev->state = status->state;
>> Â ÂÂÂÂÂ return 0;
>> Â }
>> @@ -535,6 +523,7 @@ static int sev_update_firmware(struct device *dev)
>> Â Â static int sev_ioctl_do_pek_import(struct sev_issue_cmd *argp)
>> Â {
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ struct sev_user_data_pek_cert_import input;
>> ÂÂÂÂÂ struct sev_data_pek_cert_import *data;
>> ÂÂÂÂÂ void *pek_blob, *oca_blob;
>> @@ -568,7 +557,7 @@ static int sev_ioctl_do_pek_import(struct sev_issue_cmd *argp)
>> ÂÂÂÂÂ data->oca_cert_len = input.oca_cert_len;
>> Â ÂÂÂÂÂ /* If platform is not in INIT state then transition it to INIT */
>> -ÂÂÂ if (psp_master->sev_state != SEV_STATE_INIT) {
>> +ÂÂÂ if (sev->state != SEV_STATE_INIT) {
>> ÂÂÂÂÂÂÂÂÂ ret = __sev_platform_init_locked(&argp->error);
>> ÂÂÂÂÂÂÂÂÂ if (ret)
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ goto e_free_oca;
>> @@ -690,6 +679,7 @@ static int sev_ioctl_do_get_id(struct sev_issue_cmd *argp)
>> Â Â static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp)
>> Â {
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ struct sev_user_data_pdh_cert_export input;
>> ÂÂÂÂÂ void *pdh_blob = NULL, *cert_blob = NULL;
>> ÂÂÂÂÂ struct sev_data_pdh_cert_export *data;
>> @@ -742,7 +732,7 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp)
>> Â Â cmd:
>> ÂÂÂÂÂ /* If platform is not in INIT state then transition it to INIT. */
>> -ÂÂÂ if (psp_master->sev_state != SEV_STATE_INIT) {
>> +ÂÂÂ if (sev->state != SEV_STATE_INIT) {
>> ÂÂÂÂÂÂÂÂÂ ret = __sev_platform_init_locked(&argp->error);
>> ÂÂÂÂÂÂÂÂÂ if (ret)
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ goto e_free_cert;
>> @@ -788,7 +778,7 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg)
>> ÂÂÂÂÂ struct sev_issue_cmd input;
>> ÂÂÂÂÂ int ret = -EFAULT;
>> Â -ÂÂÂ if (!psp_master)
>> +ÂÂÂ if (!psp_master || !psp_master->sev_data)
>> ÂÂÂÂÂÂÂÂÂ return -ENODEV;
>> Â ÂÂÂÂÂ if (ioctl != SEV_ISSUE_CMD)
>> @@ -887,9 +877,9 @@ static void sev_exit(struct kref *ref)
>> ÂÂÂÂÂ misc_deregister(&misc_dev->misc);
>> Â }
>> Â -static int sev_misc_init(struct psp_device *psp)
>> +static int sev_misc_init(struct sev_device *sev)
>> Â {
>> -ÂÂÂ struct device *dev = psp->dev;
>> +ÂÂÂ struct device *dev = sev->dev;
>> ÂÂÂÂÂ int ret;
>> Â ÂÂÂÂÂ /*
>> @@ -920,115 +910,61 @@ static int sev_misc_init(struct psp_device *psp)
>> ÂÂÂÂÂÂÂÂÂ kref_get(&misc_dev->refcount);
>> ÂÂÂÂÂ }
>> Â -ÂÂÂ init_waitqueue_head(&psp->sev_int_queue);
>> -ÂÂÂ psp->sev_misc = misc_dev;
>> +ÂÂÂ init_waitqueue_head(&sev->int_queue);
>> +ÂÂÂ sev->misc = misc_dev;
>> ÂÂÂÂÂ dev_dbg(dev, "registered SEV device\n");
>> Â ÂÂÂÂÂ return 0;
>> Â }
>> Â -static int psp_check_sev_support(struct psp_device *psp)
>> -{
>> -ÂÂÂ unsigned int val = ioread32(psp->io_regs + psp->vdata->feature_reg);
>> -
>> -ÂÂÂ /*
>> - * Check for a access to the registers. If this read returns
>> -ÂÂÂÂ * 0xffffffff, it's likely that the system is running a broken
>> -ÂÂÂÂ * BIOS which disallows access to the device. Stop here and
>> -ÂÂÂÂ * fail the PSP initialization (but not the load, as the CCP
>> -ÂÂÂÂ * could get properly initialized).
>> -ÂÂÂÂ */
>> -ÂÂÂ if (val == 0xffffffff) {
>> -ÂÂÂÂÂÂÂ dev_notice(psp->dev, "psp: unable to access the device: you might be running a broken BIOS.\n");
>> -ÂÂÂÂÂÂÂ return -ENODEV;
>> -ÂÂÂ }
>> -
>> -ÂÂÂ if (!(val & 1)) {
>> -ÂÂÂÂÂÂÂ /* Device does not support the SEV feature */
>> -ÂÂÂÂÂÂÂ dev_dbg(psp->dev, "psp does not support SEV\n");
>> -ÂÂÂÂÂÂÂ return -ENODEV;
>> -ÂÂÂ }
>> -
>> -ÂÂÂ return 0;
>> -}
>> -
>> -int psp_dev_init(struct sp_device *sp)
>> +int sev_dev_init(struct psp_device *psp)
>> Â {
>> -ÂÂÂ struct device *dev = sp->dev;
>> -ÂÂÂ struct psp_device *psp;
>> -ÂÂÂ int ret;
>> +ÂÂÂ struct device *dev = psp->dev;
>> +ÂÂÂ struct sev_device *sev;
>> +ÂÂÂ int ret = -ENOMEM;
>> Â -ÂÂÂ ret = -ENOMEM;
>> -ÂÂÂ psp = psp_alloc_struct(sp);
>> -ÂÂÂ if (!psp)
>> +ÂÂÂ sev = devm_kzalloc(dev, sizeof(*sev), GFP_KERNEL);
>> +ÂÂÂ if (!sev)
>> ÂÂÂÂÂÂÂÂÂ goto e_err;
>> Â -ÂÂÂ sp->psp_data = psp;
>> +ÂÂÂ psp->sev_data = sev;
>> Â -ÂÂÂ psp->vdata = (struct psp_vdata *)sp->dev_vdata->psp_vdata;
>> -ÂÂÂ if (!psp->vdata) {
>> -ÂÂÂÂÂÂÂ ret = -ENODEV;
>> -ÂÂÂÂÂÂÂ dev_err(dev, "missing driver data\n");
>> -ÂÂÂÂÂÂÂ goto e_err;
>> -ÂÂÂ }
>> +ÂÂÂ sev->dev = dev;
>> +ÂÂÂ sev->psp = psp;
>> Â -ÂÂÂ psp->io_regs = sp->io_map;
>> +ÂÂÂ sev->io_regs = psp->io_regs;
>> Â -ÂÂÂ ret = psp_check_sev_support(psp);
>> -ÂÂÂ if (ret)
>> -ÂÂÂÂÂÂÂ goto e_disable;
>> +ÂÂÂ psp_set_sev_irq_handler(psp, sev_irq_handler, sev);
>> Â -ÂÂÂ /* Disable and clear interrupts until ready */
>> -ÂÂÂ iowrite32(0, psp->io_regs + psp->vdata->inten_reg);
>> -ÂÂÂ iowrite32(-1, psp->io_regs + psp->vdata->intsts_reg);
>> -
>> -ÂÂÂ /* Request an irq */
>> -ÂÂÂ ret = sp_request_psp_irq(psp->sp, psp_irq_handler, psp->name, psp);
>> -ÂÂÂ if (ret) {
>> -ÂÂÂÂÂÂÂ dev_err(dev, "psp: unable to allocate an IRQ\n");
>> -ÂÂÂÂÂÂÂ goto e_err;
>> -ÂÂÂ }
>> -
>> -ÂÂÂ ret = sev_misc_init(psp);
>> +ÂÂÂ ret = sev_misc_init(sev);
>> ÂÂÂÂÂ if (ret)
>> ÂÂÂÂÂÂÂÂÂ goto e_irq;
>> Â -ÂÂÂ if (sp->set_psp_master_device)
>> -ÂÂÂÂÂÂÂ sp->set_psp_master_device(sp);
>> -
>> -ÂÂÂ /* Enable interrupt */
>> -ÂÂÂ iowrite32(-1, psp->io_regs + psp->vdata->inten_reg);
>> -
>> -ÂÂÂ dev_notice(dev, "psp enabled\n");
>> +ÂÂÂ dev_notice(dev, "sev enabled\n");
>> Â ÂÂÂÂÂ return 0;
>> Â Â e_irq:
>> -ÂÂÂ sp_free_psp_irq(psp->sp, psp);
>> +ÂÂÂ psp_clear_sev_irq_handler(psp);
>> Â e_err:
>> -ÂÂÂ sp->psp_data = NULL;
>> +ÂÂÂ psp->sev_data = NULL;
>> Â -ÂÂÂ dev_notice(dev, "psp initialization failed\n");
>> -
>> -ÂÂÂ return ret;
>> -
>> -e_disable:
>> -ÂÂÂ sp->psp_data = NULL;
>> +ÂÂÂ dev_notice(dev, "sev initialization failed\n");
>> Â ÂÂÂÂÂ return ret;
>> Â }
>> Â -void psp_dev_destroy(struct sp_device *sp)
>> +void sev_dev_destroy(struct psp_device *psp)
>> Â {
>> -ÂÂÂ struct psp_device *psp = sp->psp_data;
>> +ÂÂÂ struct sev_device *sev = psp->sev_data;
>> Â -ÂÂÂ if (!psp)
>> +ÂÂÂ if (!sev)
>> ÂÂÂÂÂÂÂÂÂ return;
>> Â -ÂÂÂ if (psp->sev_misc)
>> +ÂÂÂ if (sev->misc)
>> ÂÂÂÂÂÂÂÂÂ kref_put(&misc_dev->refcount, sev_exit);
>> Â -ÂÂÂ sp_free_psp_irq(sp, psp);
>> +ÂÂÂ psp_clear_sev_irq_handler(psp);
>> Â }
>> Â Â int sev_issue_cmd_external_user(struct file *filep, unsigned int cmd,
>> @@ -1037,21 +973,18 @@ int sev_issue_cmd_external_user(struct file *filep, unsigned int cmd,
>> ÂÂÂÂÂ if (!filep || filep->f_op != &sev_fops)
>> ÂÂÂÂÂÂÂÂÂ return -EBADF;
>>  - return sev_do_cmd(cmd, data, error);
>> +ÂÂÂ return sev_do_cmd(cmd, data, error);
>> Â }
>> Â EXPORT_SYMBOL_GPL(sev_issue_cmd_external_user);
>> Â -void psp_pci_init(void)
>> +void sev_pci_init(void)
>> Â {
>> -ÂÂÂ struct sp_device *sp;
>> +ÂÂÂ struct sev_device *sev = psp_master->sev_data;
>> ÂÂÂÂÂ int error, rc;
>> Â -ÂÂÂ sp = sp_get_psp_master_device();
>> -ÂÂÂ if (!sp)
>> +ÂÂÂ if (!sev)
>> ÂÂÂÂÂÂÂÂÂ return;
>> Â -ÂÂÂ psp_master = sp->psp_data;
>> -
>> ÂÂÂÂÂ psp_timeout = psp_probe_timeout;
>> Â ÂÂÂÂÂ if (sev_get_api_version())
>> @@ -1067,13 +1000,13 @@ void psp_pci_init(void)
>> ÂÂÂÂÂÂ * firmware in INIT or WORKING state.
>> ÂÂÂÂÂÂ */
>> Â -ÂÂÂ if (psp_master->sev_state != SEV_STATE_UNINIT) {
>> +ÂÂÂ if (sev->state != SEV_STATE_UNINIT) {
>> ÂÂÂÂÂÂÂÂÂ sev_platform_shutdown(NULL);
>> -ÂÂÂÂÂÂÂ psp_master->sev_state = SEV_STATE_UNINIT;
>> +ÂÂÂÂÂÂÂ sev->state = SEV_STATE_UNINIT;
>> ÂÂÂÂÂ }
>> Â ÂÂÂÂÂ if (sev_version_greater_or_equal(0, 15) &&
>> -ÂÂÂÂÂÂÂ sev_update_firmware(psp_master->dev) == 0)
>> +ÂÂÂÂÂÂÂ sev_update_firmware(sev->dev) == 0)
>> ÂÂÂÂÂÂÂÂÂ sev_get_api_version();
>> Â ÂÂÂÂÂ /* Initialize the platform */
>> @@ -1086,27 +1019,27 @@ void psp_pci_init(void)
>> ÂÂÂÂÂÂÂÂÂÂ * failed and persistent state has been erased.
>> ÂÂÂÂÂÂÂÂÂÂ * Retrying INIT command here should succeed.
>> ÂÂÂÂÂÂÂÂÂÂ */
>> -ÂÂÂÂÂÂÂ dev_dbg(sp->dev, "SEV: retrying INIT command");
>> +ÂÂÂÂÂÂÂ dev_dbg(sev->dev, "SEV: retrying INIT command");
>> ÂÂÂÂÂÂÂÂÂ rc = sev_platform_init(&error);
>> ÂÂÂÂÂ }
>> Â ÂÂÂÂÂ if (rc) {
>> -ÂÂÂÂÂÂÂ dev_err(sp->dev, "SEV: failed to INIT error %#x\n", error);
>> +ÂÂÂÂÂÂÂ dev_err(sev->dev, "SEV: failed to INIT error %#x\n", error);
>> ÂÂÂÂÂÂÂÂÂ return;
>> ÂÂÂÂÂ }
>> Â -ÂÂÂ dev_info(sp->dev, "SEV API:%d.%d build:%d\n", psp_master->api_major,
>> -ÂÂÂÂÂÂÂÂ psp_master->api_minor, psp_master->build);
>> +ÂÂÂ dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
>> +ÂÂÂÂÂÂÂÂ sev->api_minor, sev->build);
>> Â ÂÂÂÂÂ return;
>> Â Â err:
>> -ÂÂÂ psp_master = NULL;
>> +ÂÂÂ psp_master->sev_data = NULL;
>> Â }
>> Â -void psp_pci_exit(void)
>> +void sev_pci_exit(void)
>> Â {
>> -ÂÂÂ if (!psp_master)
>> +ÂÂÂ if (!psp_master->sev_data)
>> ÂÂÂÂÂÂÂÂÂ return;
>> Â ÂÂÂÂÂ sev_platform_shutdown(NULL);
>> diff --git a/drivers/crypto/ccp/sev-dev.h b/drivers/crypto/ccp/sev-dev.h
>> index c178d9f..d54fce1 100644
>> --- a/drivers/crypto/ccp/sev-dev.h
>> +++ b/drivers/crypto/ccp/sev-dev.h
>> @@ -24,37 +24,25 @@
>> Â #include <linux/psp-sev.h>
>> Â #include <linux/miscdevice.h>
>> Â -#include "sp-dev.h"
>> -
>> -#define PSP_CMD_COMPLETEÂÂÂÂÂÂÂ BIT(1)
>> -
>> -#define PSP_CMDRESP_CMD_SHIFTÂÂÂÂÂÂÂ 16
>> -#define PSP_CMDRESP_IOCÂÂÂÂÂÂÂÂÂÂÂ BIT(0)
>> -#define PSP_CMDRESP_RESPÂÂÂÂÂÂÂ BIT(31)
>> -#define PSP_CMDRESP_ERR_MASKÂÂÂÂÂÂÂ 0xffff
>> -
>> -#define MAX_PSP_NAME_LENÂÂÂÂÂÂÂ 16
>> +#define SEV_CMD_COMPLETEÂÂÂÂÂÂÂ BIT(1)
>> +#define SEV_CMDRESP_CMD_SHIFTÂÂÂÂÂÂÂ 16
>> +#define SEV_CMDRESP_IOCÂÂÂÂÂÂÂÂÂÂÂ BIT(0)
>> Â Â struct sev_misc_dev {
>> ÂÂÂÂÂ struct kref refcount;
>> ÂÂÂÂÂ struct miscdevice misc;
>> Â };
>> Â -struct psp_device {
>> -ÂÂÂ struct list_head entry;
>> -
>> -ÂÂÂ struct psp_vdata *vdata;
>> -ÂÂÂ char name[MAX_PSP_NAME_LEN];
>> -
>> +struct sev_device {
>> ÂÂÂÂÂ struct device *dev;
>> -ÂÂÂ struct sp_device *sp;
>> +ÂÂÂ struct psp_device *psp;
>> Â ÂÂÂÂÂ void __iomem *io_regs;
>> Â -ÂÂÂ int sev_state;
>> -ÂÂÂ unsigned int sev_int_rcvd;
>> -ÂÂÂ wait_queue_head_t sev_int_queue;
>> -ÂÂÂ struct sev_misc_dev *sev_misc;
>> +ÂÂÂ int state;
>> +ÂÂÂ unsigned int int_rcvd;
>> +ÂÂÂ wait_queue_head_t int_queue;
>> +ÂÂÂ struct sev_misc_dev *misc;
>> ÂÂÂÂÂ struct sev_user_data_status status_cmd_buf;
>> ÂÂÂÂÂ struct sev_data_init init_cmd_buf;
>> Â @@ -63,4 +51,10 @@ struct psp_device {
>> ÂÂÂÂÂ u8 build;
>> Â };
>> Â +int sev_dev_init(struct psp_device *psp);
>> +void sev_dev_destroy(struct psp_device *psp);
>> +
>> +void sev_pci_init(void);
>> +void sev_pci_exit(void);
>> +
>> Â #endif /* __SEV_DEV_H */
>> diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
>> index 473cf14..b29d2e6 100644
>> --- a/drivers/crypto/ccp/sp-pci.c
>> +++ b/drivers/crypto/ccp/sp-pci.c
>> @@ -22,7 +22,7 @@
>> Â #include <linux/ccp.h>
>> Â Â #include "ccp-dev.h"
>> -#include "sev-dev.h"
>> +#include "psp-dev.h"
>> Â Â #define MSIX_VECTORSÂÂÂÂÂÂÂÂÂÂÂ 2
>> Â
>