arch/loongarch/include/asm/kvm_host.h

Source file repositories/reference/linux-study-clean/arch/loongarch/include/asm/kvm_host.h

File Facts

System
Linux kernel
Corpus path
arch/loongarch/include/asm/kvm_host.h
Extension
.h
Size
9932 bytes
Lines
369
Domain
Architecture Layer
Bucket
arch/loongarch
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 kvm_vm_stat {
	struct kvm_vm_stat_generic generic;
	u64 pages;
	u64 hugepages;
};

struct kvm_vcpu_stat {
	struct kvm_vcpu_stat_generic generic;
	u64 int_exits;
	u64 idle_exits;
	u64 cpucfg_exits;
	u64 signal_exits;
	u64 hypercall_exits;
	u64 ipi_read_exits;
	u64 ipi_write_exits;
	u64 eiointc_read_exits;
	u64 eiointc_write_exits;
	u64 pch_pic_read_exits;
	u64 pch_pic_write_exits;
};

#define KVM_MEM_HUGEPAGE_CAPABLE	(1UL << 0)
#define KVM_MEM_HUGEPAGE_INCAPABLE	(1UL << 1)
struct kvm_arch_memory_slot {
	unsigned long flags;
};

#define HOST_MAX_PMNUM			16
struct kvm_context {
	unsigned long vpid_cache;
	struct kvm_vcpu *last_vcpu;
	/* Host PMU CSR */
	u64 perf_ctrl[HOST_MAX_PMNUM];
	u64 perf_cntr[HOST_MAX_PMNUM];
};

struct kvm_world_switch {
	int (*exc_entry)(void);
	int (*enter_guest)(struct kvm_run *run, struct kvm_vcpu *vcpu);
};

#define MAX_PGTABLE_LEVELS	4

/*
 * Physical CPUID is used for interrupt routing, there are different
 * definitions about physical cpuid on different hardwares.
 *
 *  For LOONGARCH_CSR_CPUID register, max CPUID size if 512
 *  For IPI hardware, max destination CPUID size 1024
 *  For eiointc interrupt controller, max destination CPUID size is 256
 *  For msgint interrupt controller, max supported CPUID size is 65536
 *
 * Currently max CPUID is defined as 256 for KVM hypervisor, in future
 * it will be expanded to 4096, including 16 packages at most. And every
 * package supports at most 256 vcpus
 */
#define KVM_MAX_PHYID		256

struct kvm_phyid_info {
	struct kvm_vcpu	*vcpu;
	bool		enabled;
};

struct kvm_phyid_map {
	int max_phyid;
	struct kvm_phyid_info phys_map[KVM_MAX_PHYID];
};

struct kvm_arch {
	/* Guest physical mm */
	kvm_pte_t *pgd;
	unsigned long gpa_size;
	unsigned long invalid_ptes[MAX_PGTABLE_LEVELS];
	unsigned int  pte_shifts[MAX_PGTABLE_LEVELS];
	unsigned int  root_level;
	spinlock_t    phyid_map_lock;
	struct kvm_phyid_map  *phyid_map;
	/* Enabled PV features */
	unsigned long pv_features;
	/* Supported KVM features */
	unsigned long kvm_features;

	s64 time_offset;
	struct kvm_context __percpu *vmcs;
	struct loongarch_ipi *ipi;
	struct loongarch_dmsintc *dmsintc;
	struct loongarch_eiointc *eiointc;
	struct loongarch_pch_pic *pch_pic;
};

Annotation

Implementation Notes