1 /* 2 * s390x Ultravisor related definitions 3 * 4 * Copyright (c) 2020 IBM Corp 5 * 6 * Authors: 7 * Janosch Frank <frankja@linux.ibm.com> 8 * 9 * This code is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License version 2. 11 */ 12 #ifndef UV_H 13 #define UV_H 14 15 #define UVC_RC_EXECUTED 0x0001 16 #define UVC_RC_INV_CMD 0x0002 17 #define UVC_RC_INV_STATE 0x0003 18 #define UVC_RC_INV_LEN 0x0005 19 #define UVC_RC_NO_RESUME 0x0007 20 21 #define UVC_CMD_QUI 0x0001 22 #define UVC_CMD_SET_SHARED_ACCESS 0x1000 23 #define UVC_CMD_REMOVE_SHARED_ACCESS 0x1001 24 25 /* Bits in installed uv calls */ 26 enum uv_cmds_inst { 27 BIT_UVC_CMD_QUI = 0, 28 BIT_UVC_CMD_SET_SHARED_ACCESS = 8, 29 BIT_UVC_CMD_REMOVE_SHARED_ACCESS = 9, 30 }; 31 32 struct uv_cb_header { 33 u16 len; 34 u16 cmd; /* Command Code */ 35 u16 rc; /* Response Code */ 36 u16 rrc; /* Return Reason Code */ 37 } __attribute__((packed)) __attribute__((aligned(8))); 38 39 struct uv_cb_qui { 40 struct uv_cb_header header; 41 u64 reserved08; 42 u64 inst_calls_list[4]; 43 u64 reserved30[15]; 44 } __attribute__((packed)) __attribute__((aligned(8))); 45 46 struct uv_cb_share { 47 struct uv_cb_header header; 48 u64 reserved08[3]; 49 u64 paddr; 50 u64 reserved28; 51 } __attribute__((packed)) __attribute__((aligned(8))); 52 53 static inline int uv_call(unsigned long r1, unsigned long r2) 54 { 55 int cc; 56 57 /* 58 * The brc instruction will take care of the cc 2/3 case where 59 * we need to continue the execution because we were 60 * interrupted. The inline assembly will only return on 61 * success/error i.e. cc 0/1. 62 */ 63 asm volatile( 64 "0: .insn rrf,0xB9A40000,%[r1],%[r2],0,0\n" 65 " brc 3,0b\n" 66 " ipm %[cc]\n" 67 " srl %[cc],28\n" 68 : [cc] "=d" (cc) 69 : [r1] "a" (r1), [r2] "a" (r2) 70 : "memory", "cc"); 71 return cc; 72 } 73 74 #endif 75