forked from torvalds/linux
/
gunyah.h
104 lines (85 loc) · 2.19 KB
/
gunyah.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _UAPI_LINUX_GUNYAH
#define _UAPI_LINUX_GUNYAH
/*
* Userspace interface for /dev/gunyah - gunyah based virtual machine
*/
#include <linux/types.h>
#include <linux/ioctl.h>
#define GH_IOCTL_TYPE 'G'
/*
* ioctls for /dev/gunyah fds:
*/
#define GH_CREATE_VM _IO(GH_IOCTL_TYPE, 0x0) /* Returns a Gunyah VM fd */
/*
* ioctls for VM fds
*/
struct gh_userspace_memory_region {
__u32 label;
#define GH_MEM_ALLOW_READ (1UL << 0)
#define GH_MEM_ALLOW_WRITE (1UL << 1)
#define GH_MEM_ALLOW_EXEC (1UL << 2)
/*
* The guest will be lent the memory instead of shared.
* In other words, the guest has exclusive access to the memory region and the host loses access.
*/
#define GH_MEM_LENT (1UL << 3)
__u32 flags;
__u64 guest_phys_addr;
__u64 memory_size;
__u64 userspace_addr;
};
#define GH_VM_SET_USER_MEM_REGION _IOW(GH_IOCTL_TYPE, 0x1, \
struct gh_userspace_memory_region)
struct gh_vm_dtb_config {
__u64 gpa;
__u64 size;
};
#define GH_VM_SET_DTB_CONFIG _IOW(GH_IOCTL_TYPE, 0x2, struct gh_vm_dtb_config)
#define GH_VM_START _IO(GH_IOCTL_TYPE, 0x3)
#define GUNYAH_FUNCTION_NAME_SIZE 32
#define GUNYAH_FUNCTION_MAX_ARG_SIZE 1024
struct gh_fn_vcpu_arg {
__u32 vcpu_id;
};
struct gh_fn_irqfd_arg {
__u32 fd;
__u32 label;
#define GH_IRQFD_LEVEL (1UL << 0)
#define GH_IRQFD_DEASSIGN (1UL << 1)
__u32 flags;
};
struct gh_vm_function {
char name[GUNYAH_FUNCTION_NAME_SIZE];
union {
struct gh_fn_vcpu_arg vcpu;
struct gh_fn_irqfd_arg irqfd;
char data[GUNYAH_FUNCTION_MAX_ARG_SIZE];
};
};
#define GH_VM_ADD_FUNCTION _IOW(GH_IOCTL_TYPE, 0x4, struct gh_vm_function)
/* for GH_VCPU_RUN, returned by mmap(vcpu_fd, offset=0) */
struct gh_vcpu_run {
/* in */
__u8 immediate_exit;
__u8 padding1[7];
/* out */
#define GH_VM_EXIT_UNKNOWN 0
#define GH_VM_EXIT_MMIO 1
__u32 exit_reason;
union {
/* GH_VM_EXIT_MMIO */
struct {
__u64 phys_addr;
__u8 data[8];
__u32 len;
__u8 is_write;
} mmio;
};
};
#define GH_VCPU_RUN _IO(GH_IOCTL_TYPE, 0x5)
#define GH_VCPU_MMAP_SIZE _IO(GH_IOCTL_TYPE, 0x6)
#endif