Path: blob/master/tools/testing/selftests/kvm/include/s390/facility.h
49255 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright IBM Corp. 20243*4* Authors:5* Hariharan Mari <[email protected]>6*7* Get the facility bits with the STFLE instruction8*/910#ifndef SELFTEST_KVM_FACILITY_H11#define SELFTEST_KVM_FACILITY_H1213#include <linux/bitops.h>1415/* alt_stfle_fac_list[16] + stfle_fac_list[16] */16#define NB_STFL_DOUBLEWORDS 321718extern uint64_t stfl_doublewords[NB_STFL_DOUBLEWORDS];19extern bool stfle_flag;2021static inline bool test_bit_inv(unsigned long nr, const unsigned long *ptr)22{23return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);24}2526static inline void stfle(uint64_t *fac, unsigned int nb_doublewords)27{28register unsigned long r0 asm("0") = nb_doublewords - 1;2930asm volatile(" .insn s,0xb2b00000,0(%1)\n"31: "+d" (r0)32: "a" (fac)33: "memory", "cc");34}3536static inline void setup_facilities(void)37{38stfle(stfl_doublewords, NB_STFL_DOUBLEWORDS);39stfle_flag = true;40}4142static inline bool test_facility(int nr)43{44if (!stfle_flag)45setup_facilities();46return test_bit_inv(nr, stfl_doublewords);47}4849#endif505152