tools/testing/selftests/kvm/include/loongarch/processor.h

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/kvm/include/loongarch/processor.h
Extension
.h
Size
6531 bytes
Lines
236
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

struct ex_regs {
	unsigned long regs[EXREGS_GPRS];
	unsigned long pc;
	unsigned long estat;
	unsigned long badv;
	unsigned long prmd;
};

#define PC_OFFSET_EXREGS		offsetof(struct ex_regs, pc)
#define ESTAT_OFFSET_EXREGS		offsetof(struct ex_regs, estat)
#define BADV_OFFSET_EXREGS		offsetof(struct ex_regs, badv)
#define PRMD_OFFSET_EXREGS		offsetof(struct ex_regs, prmd)
#define EXREGS_SIZE			sizeof(struct ex_regs)

#define VECTOR_NUM			64

typedef void(*handler_fn)(struct ex_regs *);

struct handlers {
	handler_fn exception_handlers[VECTOR_NUM];
};

void loongarch_vcpu_setup(struct kvm_vcpu *vcpu);
void vm_init_descriptor_tables(struct kvm_vm *vm);
void vm_install_exception_handler(struct kvm_vm *vm, int vector, handler_fn handler);

static inline void cpu_relax(void)
{
	asm volatile("nop" ::: "memory");
}

static inline void local_irq_enable(void)
{
	unsigned int flags = CSR_CRMD_IE;
	register unsigned int mask asm("$t0") = CSR_CRMD_IE;

	__asm__ __volatile__(
		"csrxchg %[val], %[mask], %[reg]\n\t"
		: [val] "+r" (flags)
		: [mask] "r" (mask), [reg] "i" (LOONGARCH_CSR_CRMD)
		: "memory");
}

static inline void local_irq_disable(void)
{
	unsigned int flags = 0;
	register unsigned int mask asm("$t0") = CSR_CRMD_IE;

	__asm__ __volatile__(
		"csrxchg %[val], %[mask], %[reg]\n\t"
		: [val] "+r" (flags)
		: [mask] "r" (mask), [reg] "i" (LOONGARCH_CSR_CRMD)
		: "memory");
}
#else
#define PC_OFFSET_EXREGS		((EXREGS_GPRS + 0) * 8)
#define ESTAT_OFFSET_EXREGS		((EXREGS_GPRS + 1) * 8)
#define BADV_OFFSET_EXREGS		((EXREGS_GPRS + 2) * 8)
#define PRMD_OFFSET_EXREGS		((EXREGS_GPRS + 3) * 8)
#define EXREGS_SIZE			((EXREGS_GPRS + 4) * 8)
#endif

#endif /* SELFTEST_KVM_PROCESSOR_H */

Annotation

Implementation Notes