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

vhost_user.h (3137B)


      1// SPDX-License-Identifier: GPL-2.0-or-later
      2/* Vhost-user protocol */
      3
      4#ifndef __VHOST_USER_H__
      5#define __VHOST_USER_H__
      6
      7/* Message flags */
      8#define VHOST_USER_FLAG_REPLY		BIT(2)
      9#define VHOST_USER_FLAG_NEED_REPLY	BIT(3)
     10/* Feature bits */
     11#define VHOST_USER_F_PROTOCOL_FEATURES	30
     12/* Protocol feature bits */
     13#define VHOST_USER_PROTOCOL_F_REPLY_ACK			3
     14#define VHOST_USER_PROTOCOL_F_SLAVE_REQ			5
     15#define VHOST_USER_PROTOCOL_F_CONFIG			9
     16#define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS	14
     17/* Vring state index masks */
     18#define VHOST_USER_VRING_INDEX_MASK	0xff
     19#define VHOST_USER_VRING_POLL_MASK	BIT(8)
     20
     21/* Supported version */
     22#define VHOST_USER_VERSION		1
     23/* Supported transport features */
     24#define VHOST_USER_SUPPORTED_F		BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES)
     25/* Supported protocol features */
     26#define VHOST_USER_SUPPORTED_PROTOCOL_F	(BIT_ULL(VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
     27					 BIT_ULL(VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
     28					 BIT_ULL(VHOST_USER_PROTOCOL_F_CONFIG) | \
     29					 BIT_ULL(VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS))
     30
     31enum vhost_user_request {
     32	VHOST_USER_GET_FEATURES = 1,
     33	VHOST_USER_SET_FEATURES = 2,
     34	VHOST_USER_SET_OWNER = 3,
     35	VHOST_USER_RESET_OWNER = 4,
     36	VHOST_USER_SET_MEM_TABLE = 5,
     37	VHOST_USER_SET_LOG_BASE = 6,
     38	VHOST_USER_SET_LOG_FD = 7,
     39	VHOST_USER_SET_VRING_NUM = 8,
     40	VHOST_USER_SET_VRING_ADDR = 9,
     41	VHOST_USER_SET_VRING_BASE = 10,
     42	VHOST_USER_GET_VRING_BASE = 11,
     43	VHOST_USER_SET_VRING_KICK = 12,
     44	VHOST_USER_SET_VRING_CALL = 13,
     45	VHOST_USER_SET_VRING_ERR = 14,
     46	VHOST_USER_GET_PROTOCOL_FEATURES = 15,
     47	VHOST_USER_SET_PROTOCOL_FEATURES = 16,
     48	VHOST_USER_GET_QUEUE_NUM = 17,
     49	VHOST_USER_SET_VRING_ENABLE = 18,
     50	VHOST_USER_SEND_RARP = 19,
     51	VHOST_USER_NET_SEND_MTU = 20,
     52	VHOST_USER_SET_SLAVE_REQ_FD = 21,
     53	VHOST_USER_IOTLB_MSG = 22,
     54	VHOST_USER_SET_VRING_ENDIAN = 23,
     55	VHOST_USER_GET_CONFIG = 24,
     56	VHOST_USER_SET_CONFIG = 25,
     57	VHOST_USER_VRING_KICK = 35,
     58};
     59
     60enum vhost_user_slave_request {
     61	VHOST_USER_SLAVE_IOTLB_MSG = 1,
     62	VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2,
     63	VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3,
     64	VHOST_USER_SLAVE_VRING_CALL = 4,
     65};
     66
     67struct vhost_user_header {
     68	/*
     69	 * Use enum vhost_user_request for outgoing messages,
     70	 * uses enum vhost_user_slave_request for incoming ones.
     71	 */
     72	u32 request;
     73	u32 flags;
     74	u32 size;
     75} __packed;
     76
     77struct vhost_user_config {
     78	u32 offset;
     79	u32 size;
     80	u32 flags;
     81	u8 payload[]; /* Variable length */
     82} __packed;
     83
     84struct vhost_user_vring_state {
     85	u32 index;
     86	u32 num;
     87} __packed;
     88
     89struct vhost_user_vring_addr {
     90	u32 index;
     91	u32 flags;
     92	u64 desc, used, avail, log;
     93} __packed;
     94
     95struct vhost_user_mem_region {
     96	u64 guest_addr;
     97	u64 size;
     98	u64 user_addr;
     99	u64 mmap_offset;
    100} __packed;
    101
    102struct vhost_user_mem_regions {
    103	u32 num;
    104	u32 padding;
    105	struct vhost_user_mem_region regions[2]; /* Currently supporting 2 */
    106} __packed;
    107
    108union vhost_user_payload {
    109	u64 integer;
    110	struct vhost_user_config config;
    111	struct vhost_user_vring_state vring_state;
    112	struct vhost_user_vring_addr vring_addr;
    113	struct vhost_user_mem_regions mem_regions;
    114};
    115
    116struct vhost_user_msg {
    117	struct vhost_user_header header;
    118	union vhost_user_payload payload;
    119} __packed;
    120
    121#endif