cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

virtio_iommu.h (3894B)


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