arch/arm64/kvm/config.c

Source file repositories/reference/linux-study-clean/arch/arm64/kvm/config.c

File Facts

System
Linux kernel
Corpus path
arch/arm64/kvm/config.c
Extension
.c
Size
52055 bytes
Lines
1748
Domain
Architecture Layer
Bucket
arch/arm64
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct reg_bits_to_feat_map {
	union {
		u64		 bits;
		struct fgt_masks *masks;
	};

#define	NEVER_FGU	BIT(0)	/* Can trap, but never UNDEF */
#define	CALL_FUNC	BIT(1)	/* Needs to evaluate tons of crap */
#define	FORCE_RESx	BIT(2)	/* Unconditional RESx */
#define	MASKS_POINTER	BIT(3)	/* Pointer to fgt_masks struct instead of bits */
#define	AS_RES1		BIT(4)	/* RES1 when not supported */
#define	REQUIRES_E2H1	BIT(5)	/* Add HCR_EL2.E2H RES1 as a pre-condition */
#define	RES1_WHEN_E2H0	BIT(6)	/* RES1 when E2H=0 and not supported */
#define	RES1_WHEN_E2H1	BIT(7)	/* RES1 when E2H=1 and not supported */

	unsigned long	flags;

	union {
		struct {
			u8	regidx;
			u8	shift;
			u8	width;
			bool	sign;
			s8	lo_lim;
		};
		bool	(*match)(struct kvm *);
	};
};

/*
 * Describes the dependencies for a given register:
 *
 * @feat_map describes the dependency for the whole register. If the
 * features the register depends on are not present, the whole
 * register is effectively RES0.
 *
 * @bit_feat_map describes the dependencies for a set of bits in that
 * register. If the features these bits depend on are not present, the
 * bits are effectively RES0.
 */
struct reg_feat_map_desc {
	const char			  *name;
	const struct reg_bits_to_feat_map feat_map;
	const struct reg_bits_to_feat_map *bit_feat_map;
	const unsigned int		  bit_feat_map_sz;
};

#define __NEEDS_FEAT_3(m, f, w, id, fld, lim)		\
	{						\
		.w	= (m),				\
		.flags = (f),				\
		.regidx	= IDREG_IDX(SYS_ ## id),	\
		.shift	= id ##_## fld ## _SHIFT,	\
		.width	= id ##_## fld ## _WIDTH,	\
		.sign	= id ##_## fld ## _SIGNED,	\
		.lo_lim	= id ##_## fld ##_## lim	\
	}

#define __NEEDS_FEAT_1(m, f, w, fun)			\
	{						\
		.w	= (m),				\
		.flags = (f) | CALL_FUNC,		\
		.match = (fun),				\
	}

#define __NEEDS_FEAT_0(m, f, w, ...)			\
	{						\
		.w	= (m),				\
		.flags = (f),				\
	}

#define __NEEDS_FEAT_FLAG(m, f, w, ...)			\
	CONCATENATE(__NEEDS_FEAT_, COUNT_ARGS(__VA_ARGS__))(m, f, w, __VA_ARGS__)

#define NEEDS_FEAT_FLAG(m, f, ...)			\
	__NEEDS_FEAT_FLAG(m, f, bits, __VA_ARGS__)

#define NEEDS_FEAT_MASKS(p, ...)				\
	__NEEDS_FEAT_FLAG(p, MASKS_POINTER, masks, __VA_ARGS__)

/*
 * Declare the dependency between a set of bits and a set of features,
 * generating a struct reg_bit_to_feat_map.
 */
#define NEEDS_FEAT(m, ...)	NEEDS_FEAT_FLAG(m, 0, __VA_ARGS__)

/* Declare fixed RESx bits */
#define FORCE_RES0(m)		NEEDS_FEAT_FLAG(m, FORCE_RESx)
#define FORCE_RES1(m)		NEEDS_FEAT_FLAG(m, FORCE_RESx | AS_RES1)

Annotation

Implementation Notes