15
15
#include <linux/errno.h>
16
16
#include <linux/bug.h>
17
17
#include <asm/page.h>
18
+ #include <asm/gmap.h>
18
19
19
20
#define UVC_RC_EXECUTED 0x0001
20
21
#define UVC_RC_INV_CMD 0x0002
23
24
#define UVC_RC_NO_RESUME 0x0007
24
25
25
26
#define UVC_CMD_QUI 0x0001
27
+ #define UVC_CMD_INIT_UV 0x000f
28
+ #define UVC_CMD_CONV_TO_SEC_STOR 0x0200
29
+ #define UVC_CMD_CONV_FROM_SEC_STOR 0x0201
30
+ #define UVC_CMD_PIN_PAGE_SHARED 0x0341
31
+ #define UVC_CMD_UNPIN_PAGE_SHARED 0x0342
26
32
#define UVC_CMD_SET_SHARED_ACCESS 0x1000
27
33
#define UVC_CMD_REMOVE_SHARED_ACCESS 0x1001
28
34
29
35
/* Bits in installed uv calls */
30
36
enum uv_cmds_inst {
31
37
BIT_UVC_CMD_QUI = 0 ,
38
+ BIT_UVC_CMD_INIT_UV = 1 ,
39
+ BIT_UVC_CMD_CONV_TO_SEC_STOR = 6 ,
40
+ BIT_UVC_CMD_CONV_FROM_SEC_STOR = 7 ,
32
41
BIT_UVC_CMD_SET_SHARED_ACCESS = 8 ,
33
42
BIT_UVC_CMD_REMOVE_SHARED_ACCESS = 9 ,
43
+ BIT_UVC_CMD_PIN_PAGE_SHARED = 21 ,
44
+ BIT_UVC_CMD_UNPIN_PAGE_SHARED = 22 ,
34
45
};
35
46
36
47
struct uv_cb_header {
@@ -44,7 +55,40 @@ struct uv_cb_qui {
44
55
struct uv_cb_header header ;
45
56
u64 reserved08 ;
46
57
u64 inst_calls_list [4 ];
47
- u64 reserved30 [15 ];
58
+ u64 reserved30 [2 ];
59
+ u64 uv_base_stor_len ;
60
+ u64 reserved48 ;
61
+ u64 conf_base_phys_stor_len ;
62
+ u64 conf_base_virt_stor_len ;
63
+ u64 conf_virt_var_stor_len ;
64
+ u64 cpu_stor_len ;
65
+ u32 reserved70 [3 ];
66
+ u32 max_num_sec_conf ;
67
+ u64 max_guest_stor_addr ;
68
+ u8 reserved88 [158 - 136 ];
69
+ u16 max_guest_cpus ;
70
+ u8 reserveda0 [200 - 160 ];
71
+ } __packed __aligned (8 );
72
+
73
+ struct uv_cb_init {
74
+ struct uv_cb_header header ;
75
+ u64 reserved08 [2 ];
76
+ u64 stor_origin ;
77
+ u64 stor_len ;
78
+ u64 reserved28 [4 ];
79
+ } __packed __aligned (8 );
80
+
81
+ struct uv_cb_cts {
82
+ struct uv_cb_header header ;
83
+ u64 reserved08 [2 ];
84
+ u64 guest_handle ;
85
+ u64 gaddr ;
86
+ } __packed __aligned (8 );
87
+
88
+ struct uv_cb_cfs {
89
+ struct uv_cb_header header ;
90
+ u64 reserved08 [2 ];
91
+ u64 paddr ;
48
92
} __packed __aligned (8 );
49
93
50
94
struct uv_cb_share {
@@ -69,6 +113,20 @@ static inline int uv_call(unsigned long r1, unsigned long r2)
69
113
return cc ;
70
114
}
71
115
116
+ struct uv_info {
117
+ unsigned long inst_calls_list [4 ];
118
+ unsigned long uv_base_stor_len ;
119
+ unsigned long guest_base_stor_len ;
120
+ unsigned long guest_virt_base_stor_len ;
121
+ unsigned long guest_virt_var_stor_len ;
122
+ unsigned long guest_cpu_stor_len ;
123
+ unsigned long max_sec_stor_addr ;
124
+ unsigned int max_num_sec_conf ;
125
+ unsigned short max_guest_cpus ;
126
+ };
127
+
128
+ extern struct uv_info uv_info ;
129
+
72
130
#ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
73
131
extern int prot_virt_guest ;
74
132
@@ -121,11 +179,40 @@ static inline int uv_remove_shared(unsigned long addr)
121
179
return share (addr , UVC_CMD_REMOVE_SHARED_ACCESS );
122
180
}
123
181
124
- void uv_query_info (void );
125
182
#else
126
183
#define is_prot_virt_guest () 0
127
184
static inline int uv_set_shared (unsigned long addr ) { return 0 ; }
128
185
static inline int uv_remove_shared (unsigned long addr ) { return 0 ; }
186
+ #endif
187
+
188
+ #if IS_ENABLED (CONFIG_KVM )
189
+ extern int prot_virt_host ;
190
+
191
+ static inline int is_prot_virt_host (void )
192
+ {
193
+ return prot_virt_host ;
194
+ }
195
+
196
+ int gmap_make_secure (struct gmap * gmap , unsigned long gaddr , void * uvcb );
197
+ int uv_convert_from_secure (unsigned long paddr );
198
+ int gmap_convert_to_secure (struct gmap * gmap , unsigned long gaddr );
199
+
200
+ void setup_uv (void );
201
+ void adjust_to_uv_max (unsigned long * vmax );
202
+ #else
203
+ #define is_prot_virt_host () 0
204
+ static inline void setup_uv (void ) {}
205
+ static inline void adjust_to_uv_max (unsigned long * vmax ) {}
206
+
207
+ static inline int uv_convert_from_secure (unsigned long paddr )
208
+ {
209
+ return 0 ;
210
+ }
211
+ #endif
212
+
213
+ #if defined(CONFIG_PROTECTED_VIRTUALIZATION_GUEST ) || IS_ENABLED (CONFIG_KVM )
214
+ void uv_query_info (void );
215
+ #else
129
216
static inline void uv_query_info (void ) {}
130
217
#endif
131
218
0 commit comments