tools/testing/selftests/kvm/include/s390/facility.h

Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/include/s390/facility.h

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/kvm/include/s390/facility.h
Extension
.h
Size
1046 bytes
Lines
51
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef SELFTEST_KVM_FACILITY_H
#define SELFTEST_KVM_FACILITY_H

#include <linux/bitops.h>

/* alt_stfle_fac_list[16] + stfle_fac_list[16] */
#define NB_STFL_DOUBLEWORDS 32

extern u64 stfl_doublewords[NB_STFL_DOUBLEWORDS];
extern bool stfle_flag;

static inline bool test_bit_inv(unsigned long nr, const unsigned long *ptr)
{
	return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
}

static inline void stfle(u64 *fac, unsigned int nb_doublewords)
{
	register unsigned long r0 asm("0") = nb_doublewords - 1;

	asm volatile("	.insn	s,0xb2b00000,0(%1)\n"
			: "+d" (r0)
			: "a" (fac)
			: "memory", "cc");
}

static inline void setup_facilities(void)
{
	stfle(stfl_doublewords, NB_STFL_DOUBLEWORDS);
	stfle_flag = true;
}

static inline bool test_facility(int nr)
{
	if (!stfle_flag)
		setup_facilities();
	return test_bit_inv(nr, stfl_doublewords);
}

#endif

Annotation

Implementation Notes