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

virtio_iommu.h (3941B)


      1/* SPDX-License-Identifier: BSD-3-Clause */
      2/*
      3 * Virtio-iommu definition v0.12
      4 *
      5 * Copyright (C) 2019 Arm Ltd.
      6 */
      7#ifndef _UAPI_LINUX_VIRTIO_IOMMU_H
      8#define _UAPI_LINUX_VIRTIO_IOMMU_H
      9
     10#include <linux/types.h>
     11
     12/* Feature bits */
     13#define VIRTIO_IOMMU_F_INPUT_RANGE		0
     14#define VIRTIO_IOMMU_F_DOMAIN_RANGE		1
     15#define VIRTIO_IOMMU_F_MAP_UNMAP		2
     16#define VIRTIO_IOMMU_F_BYPASS			3
     17#define VIRTIO_IOMMU_F_PROBE			4
     18#define VIRTIO_IOMMU_F_MMIO			5
     19#define VIRTIO_IOMMU_F_BYPASS_CONFIG		6
     20
     21struct virtio_iommu_range_64 {
     22	__le64					start;
     23	__le64					end;
     24};
     25
     26struct virtio_iommu_range_32 {
     27	__le32					start;
     28	__le32					end;
     29};
     30
     31struct virtio_iommu_config {
     32	/* Supported page sizes */
     33	__le64					page_size_mask;
     34	/* Supported IOVA range */
     35	struct virtio_iommu_range_64		input_range;
     36	/* Max domain ID size */
     37	struct virtio_iommu_range_32		domain_range;
     38	/* Probe buffer size */
     39	__le32					probe_size;
     40	__u8					bypass;
     41	__u8					reserved[3];
     42};
     43
     44/* Request types */
     45#define VIRTIO_IOMMU_T_ATTACH			0x01
     46#define VIRTIO_IOMMU_T_DETACH			0x02
     47#define VIRTIO_IOMMU_T_MAP			0x03
     48#define VIRTIO_IOMMU_T_UNMAP			0x04
     49#define VIRTIO_IOMMU_T_PROBE			0x05
     50
     51/* Status types */
     52#define VIRTIO_IOMMU_S_OK			0x00
     53#define VIRTIO_IOMMU_S_IOERR			0x01
     54#define VIRTIO_IOMMU_S_UNSUPP			0x02
     55#define VIRTIO_IOMMU_S_DEVERR			0x03
     56#define VIRTIO_IOMMU_S_INVAL			0x04
     57#define VIRTIO_IOMMU_S_RANGE			0x05
     58#define VIRTIO_IOMMU_S_NOENT			0x06
     59#define VIRTIO_IOMMU_S_FAULT			0x07
     60#define VIRTIO_IOMMU_S_NOMEM			0x08
     61
     62struct virtio_iommu_req_head {
     63	__u8					type;
     64	__u8					reserved[3];
     65};
     66
     67struct virtio_iommu_req_tail {
     68	__u8					status;
     69	__u8					reserved[3];
     70};
     71
     72#define VIRTIO_IOMMU_ATTACH_F_BYPASS		(1 << 0)
     73
     74struct virtio_iommu_req_attach {
     75	struct virtio_iommu_req_head		head;
     76	__le32					domain;
     77	__le32					endpoint;
     78	__le32					flags;
     79	__u8					reserved[4];
     80	struct virtio_iommu_req_tail		tail;
     81};
     82
     83struct virtio_iommu_req_detach {
     84	struct virtio_iommu_req_head		head;
     85	__le32					domain;
     86	__le32					endpoint;
     87	__u8					reserved[8];
     88	struct virtio_iommu_req_tail		tail;
     89};
     90
     91#define VIRTIO_IOMMU_MAP_F_READ			(1 << 0)
     92#define VIRTIO_IOMMU_MAP_F_WRITE		(1 << 1)
     93#define VIRTIO_IOMMU_MAP_F_MMIO			(1 << 2)
     94
     95#define VIRTIO_IOMMU_MAP_F_MASK			(VIRTIO_IOMMU_MAP_F_READ |	\
     96						 VIRTIO_IOMMU_MAP_F_WRITE |	\
     97						 VIRTIO_IOMMU_MAP_F_MMIO)
     98
     99struct virtio_iommu_req_map {
    100	struct virtio_iommu_req_head		head;
    101	__le32					domain;
    102	__le64					virt_start;
    103	__le64					virt_end;
    104	__le64					phys_start;
    105	__le32					flags;
    106	struct virtio_iommu_req_tail		tail;
    107};
    108
    109struct virtio_iommu_req_unmap {
    110	struct virtio_iommu_req_head		head;
    111	__le32					domain;
    112	__le64					virt_start;
    113	__le64					virt_end;
    114	__u8					reserved[4];
    115	struct virtio_iommu_req_tail		tail;
    116};
    117
    118#define VIRTIO_IOMMU_PROBE_T_NONE		0
    119#define VIRTIO_IOMMU_PROBE_T_RESV_MEM		1
    120
    121#define VIRTIO_IOMMU_PROBE_T_MASK		0xfff
    122
    123struct virtio_iommu_probe_property {
    124	__le16					type;
    125	__le16					length;
    126};
    127
    128#define VIRTIO_IOMMU_RESV_MEM_T_RESERVED	0
    129#define VIRTIO_IOMMU_RESV_MEM_T_MSI		1
    130
    131struct virtio_iommu_probe_resv_mem {
    132	struct virtio_iommu_probe_property	head;
    133	__u8					subtype;
    134	__u8					reserved[3];
    135	__le64					start;
    136	__le64					end;
    137};
    138
    139struct virtio_iommu_req_probe {
    140	struct virtio_iommu_req_head		head;
    141	__le32					endpoint;
    142	__u8					reserved[64];
    143
    144	__u8					properties[];
    145
    146	/*
    147	 * Tail follows the variable-length properties array. No padding,
    148	 * property lengths are all aligned on 8 bytes.
    149	 */
    150};
    151
    152/* Fault types */
    153#define VIRTIO_IOMMU_FAULT_R_UNKNOWN		0
    154#define VIRTIO_IOMMU_FAULT_R_DOMAIN		1
    155#define VIRTIO_IOMMU_FAULT_R_MAPPING		2
    156
    157#define VIRTIO_IOMMU_FAULT_F_READ		(1 << 0)
    158#define VIRTIO_IOMMU_FAULT_F_WRITE		(1 << 1)
    159#define VIRTIO_IOMMU_FAULT_F_EXEC		(1 << 2)
    160#define VIRTIO_IOMMU_FAULT_F_ADDRESS		(1 << 8)
    161
    162struct virtio_iommu_fault {
    163	__u8					reason;
    164	__u8					reserved[3];
    165	__le32					flags;
    166	__le32					endpoint;
    167	__u8					reserved2[4];
    168	__le64					address;
    169};
    170
    171#endif