1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright IBM Corp. 2017, 2022 4 * Author(s): Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> 5 * Nico Boehr <nrb@linux.ibm.com> 6 */ 7 #include <asm/interrupt.h> 8 9 #ifndef PAGE_STATES_H 10 #define PAGE_STATES_H 11 12 #define ESSA_GET_STATE 0 13 #define ESSA_SET_STABLE 1 14 #define ESSA_SET_UNUSED 2 15 #define ESSA_SET_VOLATILE 3 16 #define ESSA_SET_POT_VOLATILE 4 17 #define ESSA_SET_STABLE_RESIDENT 5 18 #define ESSA_SET_STABLE_IF_RESIDENT 6 19 #define ESSA_SET_STABLE_NODAT 7 20 21 #define ESSA_MAX ESSA_SET_STABLE_NODAT 22 23 #define ESSA_USAGE_STABLE 0 24 #define ESSA_USAGE_UNUSED 1 25 #define ESSA_USAGE_POT_VOLATILE 2 26 #define ESSA_USAGE_VOLATILE 3 27 28 static unsigned long essa(uint8_t state, unsigned long paddr) 29 { 30 uint64_t extr_state; 31 32 asm volatile(".insn rrf,0xb9ab0000,%[extr_state],%[addr],%[new_state],0" \ 33 : [extr_state] "=d" (extr_state) \ 34 : [addr] "a" (paddr), [new_state] "i" (state)); 35 36 return (unsigned long)extr_state; 37 } 38 39 /* 40 * Unfortunately the availability is not indicated by stfl bits, but 41 * we have to try to execute it and test for an operation exception. 42 */ 43 static inline bool check_essa_available(void) 44 { 45 expect_pgm_int(); 46 essa(ESSA_GET_STATE, 0); 47 return clear_pgm_int() == 0; 48 } 49 50 #endif 51