File Index
Files and directories
Sign in
FILE

facility.h

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/kvm/include/s390/facility.h C
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright IBM Corp. 2024
 4 *
 5 * Authors:
 6 *  Hariharan Mari <hari55@linux.ibm.com>
 7 *
 8 * Get the facility bits with the STFLE instruction
 9 */
10
11#ifndef SELFTEST_KVM_FACILITY_H
12#define SELFTEST_KVM_FACILITY_H
13
14#include <linux/bitops.h>
15
16/* alt_stfle_fac_list[16] + stfle_fac_list[16] */
17#define NB_STFL_DOUBLEWORDS 32
18
19extern uint64_t stfl_doublewords[NB_STFL_DOUBLEWORDS];
20extern bool stfle_flag;
21
22static inline bool test_bit_inv(unsigned long nr, const unsigned long *ptr)
23{
24	return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
25}
26
27static inline void stfle(uint64_t *fac, unsigned int nb_doublewords)
28{
29	register unsigned long r0 asm("0") = nb_doublewords - 1;
30
31	asm volatile("	.insn	s,0xb2b00000,0(%1)\n"
32			: "+d" (r0)
33			: "a" (fac)
34			: "memory", "cc");
35}
36
37static inline void setup_facilities(void)
38{
39	stfle(stfl_doublewords, NB_STFL_DOUBLEWORDS);
40	stfle_flag = true;
41}
42
43static inline bool test_facility(int nr)
44{
45	if (!stfle_flag)
46		setup_facilities();
47	return test_bit_inv(nr, stfl_doublewords);
48}
49
50#endif
~/ Read-only file preview.