18c2ecf20Sopenharmony_ci/******************************************************************************
28c2ecf20Sopenharmony_ci * arch-x86/cpuid.h
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * CPUID interface to Xen.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
78c2ecf20Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
88c2ecf20Sopenharmony_ci * deal in the Software without restriction, including without limitation the
98c2ecf20Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
108c2ecf20Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
118c2ecf20Sopenharmony_ci * furnished to do so, subject to the following conditions:
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
148c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
198c2ecf20Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
208c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
218c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
228c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * Copyright (c) 2007 Citrix Systems, Inc.
258c2ecf20Sopenharmony_ci *
268c2ecf20Sopenharmony_ci * Authors:
278c2ecf20Sopenharmony_ci *    Keir Fraser <keir@xen.org>
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#ifndef __XEN_PUBLIC_ARCH_X86_CPUID_H__
318c2ecf20Sopenharmony_ci#define __XEN_PUBLIC_ARCH_X86_CPUID_H__
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * For compatibility with other hypervisor interfaces, the Xen cpuid leaves
358c2ecf20Sopenharmony_ci * can be found at the first otherwise unused 0x100 aligned boundary starting
368c2ecf20Sopenharmony_ci * from 0x40000000.
378c2ecf20Sopenharmony_ci *
388c2ecf20Sopenharmony_ci * e.g If viridian extensions are enabled for an HVM domain, the Xen cpuid
398c2ecf20Sopenharmony_ci * leaves will start at 0x40000100
408c2ecf20Sopenharmony_ci */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define XEN_CPUID_FIRST_LEAF 0x40000000
438c2ecf20Sopenharmony_ci#define XEN_CPUID_LEAF(i)    (XEN_CPUID_FIRST_LEAF + (i))
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/*
468c2ecf20Sopenharmony_ci * Leaf 1 (0x40000x00)
478c2ecf20Sopenharmony_ci * EAX: Largest Xen-information leaf. All leaves up to an including @EAX
488c2ecf20Sopenharmony_ci *      are supported by the Xen host.
498c2ecf20Sopenharmony_ci * EBX-EDX: "XenVMMXenVMM" signature, allowing positive identification
508c2ecf20Sopenharmony_ci *      of a Xen host.
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci#define XEN_CPUID_SIGNATURE_EBX 0x566e6558 /* "XenV" */
538c2ecf20Sopenharmony_ci#define XEN_CPUID_SIGNATURE_ECX 0x65584d4d /* "MMXe" */
548c2ecf20Sopenharmony_ci#define XEN_CPUID_SIGNATURE_EDX 0x4d4d566e /* "nVMM" */
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/*
578c2ecf20Sopenharmony_ci * Leaf 2 (0x40000x01)
588c2ecf20Sopenharmony_ci * EAX[31:16]: Xen major version.
598c2ecf20Sopenharmony_ci * EAX[15: 0]: Xen minor version.
608c2ecf20Sopenharmony_ci * EBX-EDX: Reserved (currently all zeroes).
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/*
648c2ecf20Sopenharmony_ci * Leaf 3 (0x40000x02)
658c2ecf20Sopenharmony_ci * EAX: Number of hypercall transfer pages. This register is always guaranteed
668c2ecf20Sopenharmony_ci *      to specify one hypercall page.
678c2ecf20Sopenharmony_ci * EBX: Base address of Xen-specific MSRs.
688c2ecf20Sopenharmony_ci * ECX: Features 1. Unused bits are set to zero.
698c2ecf20Sopenharmony_ci * EDX: Features 2. Unused bits are set to zero.
708c2ecf20Sopenharmony_ci */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Does the host support MMU_PT_UPDATE_PRESERVE_AD for this guest? */
738c2ecf20Sopenharmony_ci#define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0
748c2ecf20Sopenharmony_ci#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD  (1u<<0)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/*
778c2ecf20Sopenharmony_ci * Leaf 4 (0x40000x03)
788c2ecf20Sopenharmony_ci * Sub-leaf 0: EAX: bit 0: emulated tsc
798c2ecf20Sopenharmony_ci *                  bit 1: host tsc is known to be reliable
808c2ecf20Sopenharmony_ci *                  bit 2: RDTSCP instruction available
818c2ecf20Sopenharmony_ci *             EBX: tsc_mode: 0=default (emulate if necessary), 1=emulate,
828c2ecf20Sopenharmony_ci *                            2=no emulation, 3=no emulation + TSC_AUX support
838c2ecf20Sopenharmony_ci *             ECX: guest tsc frequency in kHz
848c2ecf20Sopenharmony_ci *             EDX: guest tsc incarnation (migration count)
858c2ecf20Sopenharmony_ci * Sub-leaf 1: EAX: tsc offset low part
868c2ecf20Sopenharmony_ci *             EBX: tsc offset high part
878c2ecf20Sopenharmony_ci *             ECX: multiplicator for tsc->ns conversion
888c2ecf20Sopenharmony_ci *             EDX: shift amount for tsc->ns conversion
898c2ecf20Sopenharmony_ci * Sub-leaf 2: EAX: host tsc frequency in kHz
908c2ecf20Sopenharmony_ci */
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci/*
938c2ecf20Sopenharmony_ci * Leaf 5 (0x40000x04)
948c2ecf20Sopenharmony_ci * HVM-specific features
958c2ecf20Sopenharmony_ci * Sub-leaf 0: EAX: Features
968c2ecf20Sopenharmony_ci * Sub-leaf 0: EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag)
978c2ecf20Sopenharmony_ci */
988c2ecf20Sopenharmony_ci#define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
998c2ecf20Sopenharmony_ci#define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized x2APIC accesses */
1008c2ecf20Sopenharmony_ci/* Memory mapped from other domains has valid IOMMU entries */
1018c2ecf20Sopenharmony_ci#define XEN_HVM_CPUID_IOMMU_MAPPINGS   (1u << 2)
1028c2ecf20Sopenharmony_ci#define XEN_HVM_CPUID_VCPU_ID_PRESENT  (1u << 3) /* vcpu id is present in EBX */
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/*
1058c2ecf20Sopenharmony_ci * Leaf 6 (0x40000x05)
1068c2ecf20Sopenharmony_ci * PV-specific parameters
1078c2ecf20Sopenharmony_ci * Sub-leaf 0: EAX: max available sub-leaf
1088c2ecf20Sopenharmony_ci * Sub-leaf 0: EBX: bits 0-7: max machine address width
1098c2ecf20Sopenharmony_ci */
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci/* Max. address width in bits taking memory hotplug into account. */
1128c2ecf20Sopenharmony_ci#define XEN_CPUID_MACHINE_ADDRESS_WIDTH_MASK (0xffu << 0)
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define XEN_CPUID_MAX_NUM_LEAVES 5
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
117