arch/x86/kvm/cpuid.h
Source file repositories/reference/linux-study-clean/arch/x86/kvm/cpuid.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kvm/cpuid.h- Extension
.h- Size
- 9088 bytes
- Lines
- 308
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
reverse_cpuid.hasm/cpu.hasm/processor.huapi/asm/kvm_para.hsmm.h
Detected Declarations
function kvm_finalize_cpu_capsfunction kvm_find_cpuid_entry2function cpuid_maxphyaddrfunction kvm_vcpu_is_legal_gpafunction kvm_vcpu_is_legal_aligned_gpafunction page_address_validfunction cpuid_entry_overridefunction guest_cpuid_hasfunction guest_cpuid_is_amd_compatiblefunction guest_cpuid_is_intel_compatiblefunction guest_cpuid_familyfunction guest_cpuid_modelfunction cpuid_model_is_consistentfunction guest_cpuid_steppingfunction cpuid_fault_enabledfunction kvm_is_cpuid_allowedfunction kvm_cpu_cap_clearfunction kvm_cpu_cap_setfunction kvm_cpu_cap_getfunction kvm_cpu_cap_hasfunction kvm_cpu_cap_check_and_setfunction guest_pv_hasfunction guest_cpu_cap_setfunction guest_cpu_cap_clearfunction guest_cpu_cap_changefunction guest_cpu_cap_hasfunction kvm_vcpu_is_legal_cr3function guest_has_spec_ctrl_msrfunction guest_has_pred_cmd_msr
Annotated Snippet
#ifndef ARCH_X86_KVM_CPUID_H
#define ARCH_X86_KVM_CPUID_H
#include "reverse_cpuid.h"
#include <asm/cpu.h>
#include <asm/processor.h>
#include <uapi/asm/kvm_para.h>
#include "smm.h"
extern u32 kvm_cpu_caps[NR_KVM_CPU_CAPS] __read_mostly;
extern bool kvm_is_configuring_cpu_caps __read_mostly;
void kvm_initialize_cpu_caps(void);
static inline void kvm_finalize_cpu_caps(void)
{
WARN_ON_ONCE(!kvm_is_configuring_cpu_caps);
kvm_is_configuring_cpu_caps = false;
}
void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu);
struct kvm_cpuid_entry2 *kvm_find_cpuid_entry2(struct kvm_cpuid_entry2 *entries,
int nent, u32 function, u64 index);
/*
* Magic value used by KVM when querying userspace-provided CPUID entries and
* doesn't care about the CPIUD index because the index of the function in
* question is not significant. Note, this magic value must have at least one
* bit set in bits[63:32] and must be consumed as a u64 by kvm_find_cpuid_entry2()
* to avoid false positives when processing guest CPUID input.
*
* KVM_CPUID_INDEX_NOT_SIGNIFICANT should never be used directly outside of
* kvm_find_cpuid_entry2() and kvm_find_cpuid_entry().
*/
#define KVM_CPUID_INDEX_NOT_SIGNIFICANT -1ull
static inline struct kvm_cpuid_entry2 *kvm_find_cpuid_entry_index(struct kvm_vcpu *vcpu,
u32 function, u32 index)
{
return kvm_find_cpuid_entry2(vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent,
function, index);
}
static inline struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
u32 function)
{
return kvm_find_cpuid_entry2(vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent,
function, KVM_CPUID_INDEX_NOT_SIGNIFICANT);
}
int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
struct kvm_cpuid_entry2 __user *entries,
unsigned int type);
int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
struct kvm_cpuid *cpuid,
struct kvm_cpuid_entry __user *entries);
int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
struct kvm_cpuid2 *cpuid,
struct kvm_cpuid_entry2 __user *entries);
int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
struct kvm_cpuid2 *cpuid,
struct kvm_cpuid_entry2 __user *entries);
bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
u32 *ecx, u32 *edx, bool exact_only);
void __init kvm_init_xstate_sizes(void);
u32 xstate_required_size(u64 xstate_bv, bool compacted);
int cpuid_query_maxphyaddr(struct kvm_vcpu *vcpu);
int cpuid_query_maxguestphyaddr(struct kvm_vcpu *vcpu);
u64 kvm_vcpu_reserved_gpa_bits_raw(struct kvm_vcpu *vcpu);
static inline int cpuid_maxphyaddr(struct kvm_vcpu *vcpu)
{
return vcpu->arch.maxphyaddr;
}
static inline bool kvm_vcpu_is_legal_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
{
return !(gpa & vcpu->arch.reserved_gpa_bits);
}
static inline bool kvm_vcpu_is_legal_aligned_gpa(struct kvm_vcpu *vcpu,
gpa_t gpa, gpa_t alignment)
{
return IS_ALIGNED(gpa, alignment) && kvm_vcpu_is_legal_gpa(vcpu, gpa);
}
static inline bool page_address_valid(struct kvm_vcpu *vcpu, gpa_t gpa)
{
Annotation
- Immediate include surface: `reverse_cpuid.h`, `asm/cpu.h`, `asm/processor.h`, `uapi/asm/kvm_para.h`, `smm.h`.
- Detected declarations: `function kvm_finalize_cpu_caps`, `function kvm_find_cpuid_entry2`, `function cpuid_maxphyaddr`, `function kvm_vcpu_is_legal_gpa`, `function kvm_vcpu_is_legal_aligned_gpa`, `function page_address_valid`, `function cpuid_entry_override`, `function guest_cpuid_has`, `function guest_cpuid_is_amd_compatible`, `function guest_cpuid_is_intel_compatible`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.