1 /* 2 * Physical memory management related functions and definitions. 3 * 4 * Copyright IBM Corp. 2018 5 * Author(s): Janosch Frank <frankja@de.ibm.com> 6 * 7 * This code is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Library General Public License version 2. 9 */ 10 #ifndef _ASM_S390_MEM_H 11 #define _ASM_S390_MEM_H 12 13 #define SKEY_ACC 0xf0 14 #define SKEY_FP 0x08 15 #define SKEY_RF 0x04 16 #define SKEY_CH 0x02 17 18 union skey { 19 struct { 20 uint8_t acc : 4; 21 uint8_t fp : 1; 22 uint8_t rf : 1; 23 uint8_t ch : 1; 24 uint8_t pad : 1; 25 } str; 26 uint8_t val; 27 }; 28 29 static inline void set_storage_key(unsigned long addr, 30 unsigned char skey, 31 int nq) 32 { 33 if (nq) 34 asm volatile(".insn rrf,0xb22b0000,%0,%1,8,0" 35 : : "d" (skey), "a" (addr)); 36 else 37 asm volatile("sske %0,%1" : : "d" (skey), "a" (addr)); 38 } 39 40 static inline unsigned long set_storage_key_mb(unsigned long addr, 41 unsigned char skey) 42 { 43 assert(test_facility(8)); 44 45 asm volatile(".insn rrf,0xb22b0000,%[skey],%[addr],1,0" 46 : [addr] "+a" (addr) : [skey] "d" (skey)); 47 return addr; 48 } 49 50 static inline unsigned char get_storage_key(unsigned long addr) 51 { 52 unsigned char skey; 53 54 asm volatile("iske %0,%1" : "=d" (skey) : "a" (addr)); 55 return skey; 56 } 57 #endif 58