1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 #ifndef _S390X_UV_H_ 3 #define _S390X_UV_H_ 4 5 #include <sie.h> 6 #include <asm/pgtable.h> 7 8 bool uv_os_is_guest(void); 9 bool uv_os_is_host(void); 10 bool uv_host_requirement_checks(void); 11 bool uv_query_test_call(unsigned int nr); 12 const struct uv_cb_qui *uv_get_query_data(void); 13 void uv_init(void); 14 int uv_setup(void); 15 void uv_create_guest(struct vm *vm); 16 void uv_destroy_guest(struct vm *vm); 17 int uv_unpack(struct vm *vm, uint64_t addr, uint64_t len, uint64_t tweak); 18 void uv_verify_load(struct vm *vm); 19 20 /* 21 * To run PV guests we need to setup a few things: 22 * - A valid primary ASCE that contains the guest memory and has the P bit set. 23 * - A valid home space ASCE for the UV calls that use home space addresses. 24 */ 25 static inline void uv_setup_asces(void) 26 { 27 uint64_t asce; 28 29 /* We need to have a valid primary ASCE to run guests. */ 30 setup_vm(); 31 32 /* Grab the ASCE which setup_vm() just set up */ 33 asce = stctg(1); 34 35 /* Copy ASCE into home space CR */ 36 lctlg(13, asce); 37 } 38 39 static inline bool uv_validity_check(struct vm *vm) 40 { 41 uint16_t vir = sie_get_validity(vm); 42 43 return vm->sblk->icptcode == ICPT_VALIDITY && (vir & 0xff00) == 0x2000; 44 } 45 46 #endif /* UV_H */ 47