xref: /freebsd/sys/contrib/xen/arch-x86/cpuid.h (revision 3a9fd8242b35884921dfc4e886f284a75870a536)
1*3a9fd824SRoger Pau Monné /******************************************************************************
2*3a9fd824SRoger Pau Monné  * arch-x86/cpuid.h
3*3a9fd824SRoger Pau Monné  *
4*3a9fd824SRoger Pau Monné  * CPUID interface to Xen.
5*3a9fd824SRoger Pau Monné  *
6*3a9fd824SRoger Pau Monné  * Permission is hereby granted, free of charge, to any person obtaining a copy
7*3a9fd824SRoger Pau Monné  * of this software and associated documentation files (the "Software"), to
8*3a9fd824SRoger Pau Monné  * deal in the Software without restriction, including without limitation the
9*3a9fd824SRoger Pau Monné  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10*3a9fd824SRoger Pau Monné  * sell copies of the Software, and to permit persons to whom the Software is
11*3a9fd824SRoger Pau Monné  * furnished to do so, subject to the following conditions:
12*3a9fd824SRoger Pau Monné  *
13*3a9fd824SRoger Pau Monné  * The above copyright notice and this permission notice shall be included in
14*3a9fd824SRoger Pau Monné  * all copies or substantial portions of the Software.
15*3a9fd824SRoger Pau Monné  *
16*3a9fd824SRoger Pau Monné  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*3a9fd824SRoger Pau Monné  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*3a9fd824SRoger Pau Monné  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*3a9fd824SRoger Pau Monné  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*3a9fd824SRoger Pau Monné  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21*3a9fd824SRoger Pau Monné  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22*3a9fd824SRoger Pau Monné  * DEALINGS IN THE SOFTWARE.
23*3a9fd824SRoger Pau Monné  *
24*3a9fd824SRoger Pau Monné  * Copyright (c) 2007 Citrix Systems, Inc.
25*3a9fd824SRoger Pau Monné  *
26*3a9fd824SRoger Pau Monné  * Authors:
27*3a9fd824SRoger Pau Monné  *    Keir Fraser <keir@xen.org>
28*3a9fd824SRoger Pau Monné  */
29*3a9fd824SRoger Pau Monné 
30*3a9fd824SRoger Pau Monné #ifndef __XEN_PUBLIC_ARCH_X86_CPUID_H__
31*3a9fd824SRoger Pau Monné #define __XEN_PUBLIC_ARCH_X86_CPUID_H__
32*3a9fd824SRoger Pau Monné 
33*3a9fd824SRoger Pau Monné /*
34*3a9fd824SRoger Pau Monné  * For compatibility with other hypervisor interfaces, the Xen cpuid leaves
35*3a9fd824SRoger Pau Monné  * can be found at the first otherwise unused 0x100 aligned boundary starting
36*3a9fd824SRoger Pau Monné  * from 0x40000000.
37*3a9fd824SRoger Pau Monné  *
38*3a9fd824SRoger Pau Monné  * e.g If viridian extensions are enabled for an HVM domain, the Xen cpuid
39*3a9fd824SRoger Pau Monné  * leaves will start at 0x40000100
40*3a9fd824SRoger Pau Monné  */
41*3a9fd824SRoger Pau Monné 
42*3a9fd824SRoger Pau Monné #define XEN_CPUID_FIRST_LEAF 0x40000000
43*3a9fd824SRoger Pau Monné #define XEN_CPUID_LEAF(i)    (XEN_CPUID_FIRST_LEAF + (i))
44*3a9fd824SRoger Pau Monné 
45*3a9fd824SRoger Pau Monné /*
46*3a9fd824SRoger Pau Monné  * Leaf 1 (0x40000x00)
47*3a9fd824SRoger Pau Monné  * EAX: Largest Xen-information leaf. All leaves up to an including @EAX
48*3a9fd824SRoger Pau Monné  *      are supported by the Xen host.
49*3a9fd824SRoger Pau Monné  * EBX-EDX: "XenVMMXenVMM" signature, allowing positive identification
50*3a9fd824SRoger Pau Monné  *      of a Xen host.
51*3a9fd824SRoger Pau Monné  */
52*3a9fd824SRoger Pau Monné #define XEN_CPUID_SIGNATURE_EBX 0x566e6558 /* "XenV" */
53*3a9fd824SRoger Pau Monné #define XEN_CPUID_SIGNATURE_ECX 0x65584d4d /* "MMXe" */
54*3a9fd824SRoger Pau Monné #define XEN_CPUID_SIGNATURE_EDX 0x4d4d566e /* "nVMM" */
55*3a9fd824SRoger Pau Monné 
56*3a9fd824SRoger Pau Monné /*
57*3a9fd824SRoger Pau Monné  * Leaf 2 (0x40000x01)
58*3a9fd824SRoger Pau Monné  * EAX[31:16]: Xen major version.
59*3a9fd824SRoger Pau Monné  * EAX[15: 0]: Xen minor version.
60*3a9fd824SRoger Pau Monné  * EBX-EDX: Reserved (currently all zeroes).
61*3a9fd824SRoger Pau Monné  */
62*3a9fd824SRoger Pau Monné 
63*3a9fd824SRoger Pau Monné /*
64*3a9fd824SRoger Pau Monné  * Leaf 3 (0x40000x02)
65*3a9fd824SRoger Pau Monné  * EAX: Number of hypercall transfer pages. This register is always guaranteed
66*3a9fd824SRoger Pau Monné  *      to specify one hypercall page.
67*3a9fd824SRoger Pau Monné  * EBX: Base address of Xen-specific MSRs.
68*3a9fd824SRoger Pau Monné  * ECX: Features 1. Unused bits are set to zero.
69*3a9fd824SRoger Pau Monné  * EDX: Features 2. Unused bits are set to zero.
70*3a9fd824SRoger Pau Monné  */
71*3a9fd824SRoger Pau Monné 
72*3a9fd824SRoger Pau Monné /* Does the host support MMU_PT_UPDATE_PRESERVE_AD for this guest? */
73*3a9fd824SRoger Pau Monné #define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0
74*3a9fd824SRoger Pau Monné #define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD  (1u<<0)
75*3a9fd824SRoger Pau Monné 
76*3a9fd824SRoger Pau Monné /*
77*3a9fd824SRoger Pau Monné  * Leaf 4 (0x40000x03)
78*3a9fd824SRoger Pau Monné  * Sub-leaf 0: EAX: bit 0: emulated tsc
79*3a9fd824SRoger Pau Monné  *                  bit 1: host tsc is known to be reliable
80*3a9fd824SRoger Pau Monné  *                  bit 2: RDTSCP instruction available
81*3a9fd824SRoger Pau Monné  *             EBX: tsc_mode: 0=default (emulate if necessary), 1=emulate,
82*3a9fd824SRoger Pau Monné  *                            2=no emulation, 3=no emulation + TSC_AUX support
83*3a9fd824SRoger Pau Monné  *             ECX: guest tsc frequency in kHz
84*3a9fd824SRoger Pau Monné  *             EDX: guest tsc incarnation (migration count)
85*3a9fd824SRoger Pau Monné  * Sub-leaf 1: EAX: tsc offset low part
86*3a9fd824SRoger Pau Monné  *             EBX: tsc offset high part
87*3a9fd824SRoger Pau Monné  *             ECX: multiplicator for tsc->ns conversion
88*3a9fd824SRoger Pau Monné  *             EDX: shift amount for tsc->ns conversion
89*3a9fd824SRoger Pau Monné  * Sub-leaf 2: EAX: host tsc frequency in kHz
90*3a9fd824SRoger Pau Monné  */
91*3a9fd824SRoger Pau Monné 
92*3a9fd824SRoger Pau Monné /*
93*3a9fd824SRoger Pau Monné  * Leaf 5 (0x40000x04)
94*3a9fd824SRoger Pau Monné  * HVM-specific features
95*3a9fd824SRoger Pau Monné  * Sub-leaf 0: EAX: Features
96*3a9fd824SRoger Pau Monné  * Sub-leaf 0: EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag)
97*3a9fd824SRoger Pau Monné  * Sub-leaf 0: ECX: domain id (iff EAX has XEN_HVM_CPUID_DOMID_PRESENT flag)
98*3a9fd824SRoger Pau Monné  */
99*3a9fd824SRoger Pau Monné #define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
100*3a9fd824SRoger Pau Monné #define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized x2APIC accesses */
101*3a9fd824SRoger Pau Monné /* Memory mapped from other domains has valid IOMMU entries */
102*3a9fd824SRoger Pau Monné #define XEN_HVM_CPUID_IOMMU_MAPPINGS   (1u << 2)
103*3a9fd824SRoger Pau Monné #define XEN_HVM_CPUID_VCPU_ID_PRESENT  (1u << 3) /* vcpu id is present in EBX */
104*3a9fd824SRoger Pau Monné #define XEN_HVM_CPUID_DOMID_PRESENT    (1u << 4) /* domid is present in ECX */
105*3a9fd824SRoger Pau Monné 
106*3a9fd824SRoger Pau Monné /*
107*3a9fd824SRoger Pau Monné  * Leaf 6 (0x40000x05)
108*3a9fd824SRoger Pau Monné  * PV-specific parameters
109*3a9fd824SRoger Pau Monné  * Sub-leaf 0: EAX: max available sub-leaf
110*3a9fd824SRoger Pau Monné  * Sub-leaf 0: EBX: bits 0-7: max machine address width
111*3a9fd824SRoger Pau Monné  */
112*3a9fd824SRoger Pau Monné 
113*3a9fd824SRoger Pau Monné /* Max. address width in bits taking memory hotplug into account. */
114*3a9fd824SRoger Pau Monné #define XEN_CPUID_MACHINE_ADDRESS_WIDTH_MASK (0xffu << 0)
115*3a9fd824SRoger Pau Monné 
116*3a9fd824SRoger Pau Monné #define XEN_CPUID_MAX_NUM_LEAVES 5
117*3a9fd824SRoger Pau Monné 
118*3a9fd824SRoger Pau Monné #endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
119