cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

sev-dev.h (1584B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * AMD Platform Security Processor (PSP) interface driver
      4 *
      5 * Copyright (C) 2017-2019 Advanced Micro Devices, Inc.
      6 *
      7 * Author: Brijesh Singh <brijesh.singh@amd.com>
      8 */
      9
     10#ifndef __SEV_DEV_H__
     11#define __SEV_DEV_H__
     12
     13#include <linux/device.h>
     14#include <linux/spinlock.h>
     15#include <linux/mutex.h>
     16#include <linux/list.h>
     17#include <linux/wait.h>
     18#include <linux/dmapool.h>
     19#include <linux/hw_random.h>
     20#include <linux/bitops.h>
     21#include <linux/interrupt.h>
     22#include <linux/irqreturn.h>
     23#include <linux/dmaengine.h>
     24#include <linux/psp-sev.h>
     25#include <linux/miscdevice.h>
     26#include <linux/capability.h>
     27
     28#define SEV_CMD_COMPLETE		BIT(1)
     29#define SEV_CMDRESP_CMD_SHIFT		16
     30#define SEV_CMDRESP_IOC			BIT(0)
     31
     32#define MAX_SNP_HOST_MAP_BUFS		2
     33
     34struct sev_misc_dev {
     35	struct kref refcount;
     36	struct miscdevice misc;
     37};
     38
     39struct snp_host_map {
     40	u64 paddr;
     41	u32 len;
     42	void *host;
     43	bool active;
     44};
     45
     46struct sev_device {
     47	struct device *dev;
     48	struct psp_device *psp;
     49
     50	void __iomem *io_regs;
     51
     52	struct sev_vdata *vdata;
     53
     54	int state;
     55	unsigned int int_rcvd;
     56	wait_queue_head_t int_queue;
     57	struct sev_misc_dev *misc;
     58
     59	u8 api_major;
     60	u8 api_minor;
     61	u8 build;
     62
     63	void *cmd_buf;
     64	void *cmd_buf_backup;
     65	int cmd_buf_active;
     66
     67	bool snp_inited;
     68	struct snp_host_map snp_host_map[MAX_SNP_HOST_MAP_BUFS];
     69	void *snp_certs_data;
     70	u32 snp_certs_len;
     71	struct sev_user_data_snp_config snp_config;
     72};
     73
     74int sev_dev_init(struct psp_device *psp);
     75void sev_dev_destroy(struct psp_device *psp);
     76
     77void sev_pci_init(void);
     78void sev_pci_exit(void);
     79
     80#endif /* __SEV_DEV_H */