xref: /linux/arch/x86/include/asm/xen/cpuid.h (revision e07e98da924e61e814bdaaa3ebc6e72b60dbf9ed)
114520c92SBoris Ostrovsky /******************************************************************************
214520c92SBoris Ostrovsky  * arch-x86/cpuid.h
314520c92SBoris Ostrovsky  *
414520c92SBoris Ostrovsky  * CPUID interface to Xen.
514520c92SBoris Ostrovsky  *
614520c92SBoris Ostrovsky  * Permission is hereby granted, free of charge, to any person obtaining a copy
714520c92SBoris Ostrovsky  * of this software and associated documentation files (the "Software"), to
814520c92SBoris Ostrovsky  * deal in the Software without restriction, including without limitation the
914520c92SBoris Ostrovsky  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1014520c92SBoris Ostrovsky  * sell copies of the Software, and to permit persons to whom the Software is
1114520c92SBoris Ostrovsky  * furnished to do so, subject to the following conditions:
1214520c92SBoris Ostrovsky  *
1314520c92SBoris Ostrovsky  * The above copyright notice and this permission notice shall be included in
1414520c92SBoris Ostrovsky  * all copies or substantial portions of the Software.
1514520c92SBoris Ostrovsky  *
1614520c92SBoris Ostrovsky  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1714520c92SBoris Ostrovsky  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1814520c92SBoris Ostrovsky  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1914520c92SBoris Ostrovsky  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2014520c92SBoris Ostrovsky  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2114520c92SBoris Ostrovsky  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2214520c92SBoris Ostrovsky  * DEALINGS IN THE SOFTWARE.
2314520c92SBoris Ostrovsky  *
2414520c92SBoris Ostrovsky  * Copyright (c) 2007 Citrix Systems, Inc.
2514520c92SBoris Ostrovsky  *
2614520c92SBoris Ostrovsky  * Authors:
2714520c92SBoris Ostrovsky  *    Keir Fraser <keir@xen.org>
2814520c92SBoris Ostrovsky  */
2914520c92SBoris Ostrovsky 
3014520c92SBoris Ostrovsky #ifndef __XEN_PUBLIC_ARCH_X86_CPUID_H__
3114520c92SBoris Ostrovsky #define __XEN_PUBLIC_ARCH_X86_CPUID_H__
3214520c92SBoris Ostrovsky 
3314520c92SBoris Ostrovsky /*
3414520c92SBoris Ostrovsky  * For compatibility with other hypervisor interfaces, the Xen cpuid leaves
3514520c92SBoris Ostrovsky  * can be found at the first otherwise unused 0x100 aligned boundary starting
3614520c92SBoris Ostrovsky  * from 0x40000000.
3714520c92SBoris Ostrovsky  *
3814520c92SBoris Ostrovsky  * e.g If viridian extensions are enabled for an HVM domain, the Xen cpuid
3914520c92SBoris Ostrovsky  * leaves will start at 0x40000100
4014520c92SBoris Ostrovsky  */
4114520c92SBoris Ostrovsky 
4214520c92SBoris Ostrovsky #define XEN_CPUID_FIRST_LEAF 0x40000000
4314520c92SBoris Ostrovsky #define XEN_CPUID_LEAF(i)    (XEN_CPUID_FIRST_LEAF + (i))
4414520c92SBoris Ostrovsky 
4514520c92SBoris Ostrovsky /*
4614520c92SBoris Ostrovsky  * Leaf 1 (0x40000x00)
4714520c92SBoris Ostrovsky  * EAX: Largest Xen-information leaf. All leaves up to an including @EAX
4814520c92SBoris Ostrovsky  *      are supported by the Xen host.
4914520c92SBoris Ostrovsky  * EBX-EDX: "XenVMMXenVMM" signature, allowing positive identification
5014520c92SBoris Ostrovsky  *      of a Xen host.
5114520c92SBoris Ostrovsky  */
5214520c92SBoris Ostrovsky #define XEN_CPUID_SIGNATURE_EBX 0x566e6558 /* "XenV" */
5314520c92SBoris Ostrovsky #define XEN_CPUID_SIGNATURE_ECX 0x65584d4d /* "MMXe" */
5414520c92SBoris Ostrovsky #define XEN_CPUID_SIGNATURE_EDX 0x4d4d566e /* "nVMM" */
5514520c92SBoris Ostrovsky 
5614520c92SBoris Ostrovsky /*
5714520c92SBoris Ostrovsky  * Leaf 2 (0x40000x01)
5814520c92SBoris Ostrovsky  * EAX[31:16]: Xen major version.
5914520c92SBoris Ostrovsky  * EAX[15: 0]: Xen minor version.
6014520c92SBoris Ostrovsky  * EBX-EDX: Reserved (currently all zeroes).
6114520c92SBoris Ostrovsky  */
6214520c92SBoris Ostrovsky 
6314520c92SBoris Ostrovsky /*
6414520c92SBoris Ostrovsky  * Leaf 3 (0x40000x02)
6514520c92SBoris Ostrovsky  * EAX: Number of hypercall transfer pages. This register is always guaranteed
6614520c92SBoris Ostrovsky  *      to specify one hypercall page.
6714520c92SBoris Ostrovsky  * EBX: Base address of Xen-specific MSRs.
6814520c92SBoris Ostrovsky  * ECX: Features 1. Unused bits are set to zero.
6914520c92SBoris Ostrovsky  * EDX: Features 2. Unused bits are set to zero.
7014520c92SBoris Ostrovsky  */
7114520c92SBoris Ostrovsky 
7214520c92SBoris Ostrovsky /* Does the host support MMU_PT_UPDATE_PRESERVE_AD for this guest? */
7314520c92SBoris Ostrovsky #define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0
7414520c92SBoris Ostrovsky #define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD  (1u<<0)
7514520c92SBoris Ostrovsky 
7614520c92SBoris Ostrovsky /*
77223c8f33SJuergen Gross  * Leaf 4 (0x40000x03)
78223c8f33SJuergen Gross  * Sub-leaf 0: EAX: bit 0: emulated tsc
79223c8f33SJuergen Gross  *                  bit 1: host tsc is known to be reliable
80223c8f33SJuergen Gross  *                  bit 2: RDTSCP instruction available
81223c8f33SJuergen Gross  *             EBX: tsc_mode: 0=default (emulate if necessary), 1=emulate,
82223c8f33SJuergen Gross  *                            2=no emulation, 3=no emulation + TSC_AUX support
83223c8f33SJuergen Gross  *             ECX: guest tsc frequency in kHz
84223c8f33SJuergen Gross  *             EDX: guest tsc incarnation (migration count)
85223c8f33SJuergen Gross  * Sub-leaf 1: EAX: tsc offset low part
86223c8f33SJuergen Gross  *             EBX: tsc offset high part
87223c8f33SJuergen Gross  *             ECX: multiplicator for tsc->ns conversion
88223c8f33SJuergen Gross  *             EDX: shift amount for tsc->ns conversion
89223c8f33SJuergen Gross  * Sub-leaf 2: EAX: host tsc frequency in kHz
9014520c92SBoris Ostrovsky  */
9114520c92SBoris Ostrovsky 
92223c8f33SJuergen Gross /*
93223c8f33SJuergen Gross  * Leaf 5 (0x40000x04)
94223c8f33SJuergen Gross  * HVM-specific features
95223c8f33SJuergen Gross  * Sub-leaf 0: EAX: Features
96223c8f33SJuergen Gross  * Sub-leaf 0: EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag)
97223c8f33SJuergen Gross  */
98223c8f33SJuergen Gross #define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
99223c8f33SJuergen Gross #define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized x2APIC accesses */
10014520c92SBoris Ostrovsky /* Memory mapped from other domains has valid IOMMU entries */
10114520c92SBoris Ostrovsky #define XEN_HVM_CPUID_IOMMU_MAPPINGS   (1u << 2)
102223c8f33SJuergen Gross #define XEN_HVM_CPUID_VCPU_ID_PRESENT  (1u << 3) /* vcpu id is present in EBX */
103*e07e98daSRoger Pau Monne #define XEN_HVM_CPUID_DOMID_PRESENT    (1u << 4) /* domid is present in ECX */
104*e07e98daSRoger Pau Monne /*
105*e07e98daSRoger Pau Monne  * Bits 55:49 from the IO-APIC RTE and bits 11:5 from the MSI address can be
106*e07e98daSRoger Pau Monne  * used to store high bits for the Destination ID. This expands the Destination
107*e07e98daSRoger Pau Monne  * ID field from 8 to 15 bits, allowing to target APIC IDs up 32768.
108*e07e98daSRoger Pau Monne  */
109*e07e98daSRoger Pau Monne #define XEN_HVM_CPUID_EXT_DEST_ID      (1u << 5)
11014520c92SBoris Ostrovsky 
111223c8f33SJuergen Gross /*
112223c8f33SJuergen Gross  * Leaf 6 (0x40000x05)
113223c8f33SJuergen Gross  * PV-specific parameters
114223c8f33SJuergen Gross  * Sub-leaf 0: EAX: max available sub-leaf
115223c8f33SJuergen Gross  * Sub-leaf 0: EBX: bits 0-7: max machine address width
116223c8f33SJuergen Gross  */
117223c8f33SJuergen Gross 
118223c8f33SJuergen Gross /* Max. address width in bits taking memory hotplug into account. */
119223c8f33SJuergen Gross #define XEN_CPUID_MACHINE_ADDRESS_WIDTH_MASK (0xffu << 0)
120223c8f33SJuergen Gross 
121223c8f33SJuergen Gross #define XEN_CPUID_MAX_NUM_LEAVES 5
12214520c92SBoris Ostrovsky 
12314520c92SBoris Ostrovsky #endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
124