1 #ifndef __X86_CPUID_H__ 2 #define __X86_CPUID_H__ 3 4 #include <asm/cpufeatureset.h> 5 6 #ifndef __ASSEMBLY__ 7 #include <xen/types.h> 8 #include <xen/kernel.h> 9 #include <xen/percpu.h> 10 11 #include <xen/lib/x86/cpu-policy.h> 12 #include <xen/lib/x86/cpuid.h> 13 14 #include <public/sysctl.h> 15 16 extern const uint32_t known_features[FSCAPINTS]; 17 extern const uint32_t special_features[FSCAPINTS]; 18 19 void init_guest_cpuid(void); 20 21 /* 22 * Expected levelling capabilities (given cpuid vendor/family information), 23 * and levelling capabilities actually available (given MSR probing). 24 */ 25 #define LCAP_faulting XEN_SYSCTL_CPU_LEVELCAP_faulting 26 #define LCAP_1cd (XEN_SYSCTL_CPU_LEVELCAP_ecx | \ 27 XEN_SYSCTL_CPU_LEVELCAP_edx) 28 #define LCAP_e1cd (XEN_SYSCTL_CPU_LEVELCAP_extd_ecx | \ 29 XEN_SYSCTL_CPU_LEVELCAP_extd_edx) 30 #define LCAP_Da1 XEN_SYSCTL_CPU_LEVELCAP_xsave_eax 31 #define LCAP_6c XEN_SYSCTL_CPU_LEVELCAP_thermal_ecx 32 #define LCAP_7ab0 (XEN_SYSCTL_CPU_LEVELCAP_l7s0_eax | \ 33 XEN_SYSCTL_CPU_LEVELCAP_l7s0_ebx) 34 extern unsigned int expected_levelling_cap, levelling_caps; 35 36 struct cpuidmasks 37 { 38 uint64_t _1cd; 39 uint64_t e1cd; 40 uint64_t Da1; 41 uint64_t _6c; 42 uint64_t _7ab0; 43 }; 44 45 /* Per CPU shadows of masking MSR values, for lazy context switching. */ 46 DECLARE_PER_CPU(struct cpuidmasks, cpuidmasks); 47 48 /* Default masking MSR values, calculated at boot. */ 49 extern struct cpuidmasks cpuidmask_defaults; 50 51 extern struct cpuid_policy raw_cpuid_policy, host_cpuid_policy, 52 pv_max_cpuid_policy, pv_def_cpuid_policy, 53 hvm_max_cpuid_policy, hvm_def_cpuid_policy; 54 55 extern const struct cpu_policy system_policies[]; 56 57 /* Check that all previously present features are still available. */ 58 bool recheck_cpu_features(unsigned int cpu); 59 60 /* Allocate and initialise a CPUID policy suitable for the domain. */ 61 int init_domain_cpuid_policy(struct domain *d); 62 63 /* Clamp the CPUID policy to reality. */ 64 void recalculate_cpuid_policy(struct domain *d); 65 66 struct vcpu; 67 void guest_cpuid(const struct vcpu *v, uint32_t leaf, 68 uint32_t subleaf, struct cpuid_leaf *res); 69 70 #endif /* __ASSEMBLY__ */ 71 #endif /* !__X86_CPUID_H__ */ 72 73 /* 74 * Local variables: 75 * mode: C 76 * c-file-style: "BSD" 77 * c-basic-offset: 4 78 * tab-width: 4 79 * indent-tabs-mode: nil 80 * End: 81 */ 82