2019-06-04 16:11:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2017-12-05 00:57:28 +08:00
|
|
|
/*
|
|
|
|
* AMD Platform Security Processor (PSP) interface driver
|
|
|
|
*
|
2019-12-04 14:18:58 +08:00
|
|
|
* Copyright (C) 2017-2019 Advanced Micro Devices, Inc.
|
2017-12-05 00:57:28 +08:00
|
|
|
*
|
|
|
|
* Author: Brijesh Singh <brijesh.singh@amd.com>
|
|
|
|
*/
|
|
|
|
|
2019-12-04 14:18:58 +08:00
|
|
|
#ifndef __SEV_DEV_H__
|
|
|
|
#define __SEV_DEV_H__
|
2017-12-05 00:57:28 +08:00
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/dmapool.h>
|
|
|
|
#include <linux/hw_random.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irqreturn.h>
|
|
|
|
#include <linux/dmaengine.h>
|
2017-12-05 00:57:28 +08:00
|
|
|
#include <linux/psp-sev.h>
|
|
|
|
#include <linux/miscdevice.h>
|
2019-11-13 03:58:34 +08:00
|
|
|
#include <linux/capability.h>
|
2017-12-05 00:57:28 +08:00
|
|
|
|
2019-12-04 14:18:59 +08:00
|
|
|
#define SEV_CMD_COMPLETE BIT(1)
|
|
|
|
#define SEV_CMDRESP_CMD_SHIFT 16
|
|
|
|
#define SEV_CMDRESP_IOC BIT(0)
|
2017-12-05 00:57:28 +08:00
|
|
|
|
2017-12-05 00:57:28 +08:00
|
|
|
struct sev_misc_dev {
|
|
|
|
struct kref refcount;
|
|
|
|
struct miscdevice misc;
|
|
|
|
};
|
|
|
|
|
2019-12-04 14:18:59 +08:00
|
|
|
struct sev_device {
|
2017-12-05 00:57:28 +08:00
|
|
|
struct device *dev;
|
2019-12-04 14:18:59 +08:00
|
|
|
struct psp_device *psp;
|
2017-12-05 00:57:28 +08:00
|
|
|
|
|
|
|
void __iomem *io_regs;
|
2017-12-05 00:57:28 +08:00
|
|
|
|
2019-12-04 14:19:00 +08:00
|
|
|
struct sev_vdata *vdata;
|
|
|
|
|
2019-12-04 14:18:59 +08:00
|
|
|
int state;
|
|
|
|
unsigned int int_rcvd;
|
|
|
|
wait_queue_head_t int_queue;
|
|
|
|
struct sev_misc_dev *misc;
|
2017-12-05 00:57:28 +08:00
|
|
|
struct sev_user_data_status status_cmd_buf;
|
|
|
|
struct sev_data_init init_cmd_buf;
|
2018-05-26 04:23:29 +08:00
|
|
|
|
|
|
|
u8 api_major;
|
|
|
|
u8 api_minor;
|
|
|
|
u8 build;
|
2017-12-05 00:57:28 +08:00
|
|
|
};
|
|
|
|
|
2019-12-04 14:18:59 +08:00
|
|
|
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);
|
|
|
|
|
2019-12-04 14:18:58 +08:00
|
|
|
#endif /* __SEV_DEV_H */
|