162306a36Sopenharmony_ci/******************************************************************************
262306a36Sopenharmony_ci * arch-x86/cpuid.h
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * CPUID interface to Xen.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
762306a36Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
862306a36Sopenharmony_ci * deal in the Software without restriction, including without limitation the
962306a36Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1062306a36Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
1162306a36Sopenharmony_ci * furnished to do so, subject to the following conditions:
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
1462306a36Sopenharmony_ci * all copies or substantial portions of the Software.
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1762306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1862306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1962306a36Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2062306a36Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2162306a36Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2262306a36Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * Copyright (c) 2007 Citrix Systems, Inc.
2562306a36Sopenharmony_ci *
2662306a36Sopenharmony_ci * Authors:
2762306a36Sopenharmony_ci *    Keir Fraser <keir@xen.org>
2862306a36Sopenharmony_ci */
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#ifndef __XEN_PUBLIC_ARCH_X86_CPUID_H__
3162306a36Sopenharmony_ci#define __XEN_PUBLIC_ARCH_X86_CPUID_H__
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/*
3462306a36Sopenharmony_ci * For compatibility with other hypervisor interfaces, the Xen cpuid leaves
3562306a36Sopenharmony_ci * can be found at the first otherwise unused 0x100 aligned boundary starting
3662306a36Sopenharmony_ci * from 0x40000000.
3762306a36Sopenharmony_ci *
3862306a36Sopenharmony_ci * e.g If viridian extensions are enabled for an HVM domain, the Xen cpuid
3962306a36Sopenharmony_ci * leaves will start at 0x40000100
4062306a36Sopenharmony_ci */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define XEN_CPUID_FIRST_LEAF 0x40000000
4362306a36Sopenharmony_ci#define XEN_CPUID_LEAF(i)    (XEN_CPUID_FIRST_LEAF + (i))
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/*
4662306a36Sopenharmony_ci * Leaf 1 (0x40000x00)
4762306a36Sopenharmony_ci * EAX: Largest Xen-information leaf. All leaves up to an including @EAX
4862306a36Sopenharmony_ci *      are supported by the Xen host.
4962306a36Sopenharmony_ci * EBX-EDX: "XenVMMXenVMM" signature, allowing positive identification
5062306a36Sopenharmony_ci *      of a Xen host.
5162306a36Sopenharmony_ci */
5262306a36Sopenharmony_ci#define XEN_CPUID_SIGNATURE_EBX 0x566e6558 /* "XenV" */
5362306a36Sopenharmony_ci#define XEN_CPUID_SIGNATURE_ECX 0x65584d4d /* "MMXe" */
5462306a36Sopenharmony_ci#define XEN_CPUID_SIGNATURE_EDX 0x4d4d566e /* "nVMM" */
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/*
5762306a36Sopenharmony_ci * Leaf 2 (0x40000x01)
5862306a36Sopenharmony_ci * EAX[31:16]: Xen major version.
5962306a36Sopenharmony_ci * EAX[15: 0]: Xen minor version.
6062306a36Sopenharmony_ci * EBX-EDX: Reserved (currently all zeroes).
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/*
6462306a36Sopenharmony_ci * Leaf 3 (0x40000x02)
6562306a36Sopenharmony_ci * EAX: Number of hypercall transfer pages. This register is always guaranteed
6662306a36Sopenharmony_ci *      to specify one hypercall page.
6762306a36Sopenharmony_ci * EBX: Base address of Xen-specific MSRs.
6862306a36Sopenharmony_ci * ECX: Features 1. Unused bits are set to zero.
6962306a36Sopenharmony_ci * EDX: Features 2. Unused bits are set to zero.
7062306a36Sopenharmony_ci */
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/* Does the host support MMU_PT_UPDATE_PRESERVE_AD for this guest? */
7362306a36Sopenharmony_ci#define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0
7462306a36Sopenharmony_ci#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD  (1u<<0)
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/*
7762306a36Sopenharmony_ci * Leaf 4 (0x40000x03)
7862306a36Sopenharmony_ci * Sub-leaf 0: EAX: bit 0: emulated tsc
7962306a36Sopenharmony_ci *                  bit 1: host tsc is known to be reliable
8062306a36Sopenharmony_ci *                  bit 2: RDTSCP instruction available
8162306a36Sopenharmony_ci *             EBX: tsc_mode: 0=default (emulate if necessary), 1=emulate,
8262306a36Sopenharmony_ci *                            2=no emulation, 3=no emulation + TSC_AUX support
8362306a36Sopenharmony_ci *             ECX: guest tsc frequency in kHz
8462306a36Sopenharmony_ci *             EDX: guest tsc incarnation (migration count)
8562306a36Sopenharmony_ci * Sub-leaf 1: EAX: tsc offset low part
8662306a36Sopenharmony_ci *             EBX: tsc offset high part
8762306a36Sopenharmony_ci *             ECX: multiplicator for tsc->ns conversion
8862306a36Sopenharmony_ci *             EDX: shift amount for tsc->ns conversion
8962306a36Sopenharmony_ci * Sub-leaf 2: EAX: host tsc frequency in kHz
9062306a36Sopenharmony_ci */
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#define XEN_CPUID_TSC_EMULATED               (1u << 0)
9362306a36Sopenharmony_ci#define XEN_CPUID_HOST_TSC_RELIABLE          (1u << 1)
9462306a36Sopenharmony_ci#define XEN_CPUID_RDTSCP_INSTR_AVAIL         (1u << 2)
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#define XEN_CPUID_TSC_MODE_DEFAULT           (0)
9762306a36Sopenharmony_ci#define XEN_CPUID_TSC_MODE_ALWAYS_EMULATE    (1u)
9862306a36Sopenharmony_ci#define XEN_CPUID_TSC_MODE_NEVER_EMULATE     (2u)
9962306a36Sopenharmony_ci#define XEN_CPUID_TSC_MODE_PVRDTSCP          (3u)
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci/*
10262306a36Sopenharmony_ci * Leaf 5 (0x40000x04)
10362306a36Sopenharmony_ci * HVM-specific features
10462306a36Sopenharmony_ci * Sub-leaf 0: EAX: Features
10562306a36Sopenharmony_ci * Sub-leaf 0: EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag)
10662306a36Sopenharmony_ci * Sub-leaf 0: ECX: domain id (iff EAX has XEN_HVM_CPUID_DOMID_PRESENT flag)
10762306a36Sopenharmony_ci */
10862306a36Sopenharmony_ci#define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
10962306a36Sopenharmony_ci#define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized x2APIC accesses */
11062306a36Sopenharmony_ci/* Memory mapped from other domains has valid IOMMU entries */
11162306a36Sopenharmony_ci#define XEN_HVM_CPUID_IOMMU_MAPPINGS   (1u << 2)
11262306a36Sopenharmony_ci#define XEN_HVM_CPUID_VCPU_ID_PRESENT  (1u << 3) /* vcpu id is present in EBX */
11362306a36Sopenharmony_ci#define XEN_HVM_CPUID_DOMID_PRESENT    (1u << 4) /* domid is present in ECX */
11462306a36Sopenharmony_ci/*
11562306a36Sopenharmony_ci * With interrupt format set to 0 (non-remappable) bits 55:49 from the
11662306a36Sopenharmony_ci * IO-APIC RTE and bits 11:5 from the MSI address can be used to store
11762306a36Sopenharmony_ci * high bits for the Destination ID. This expands the Destination ID
11862306a36Sopenharmony_ci * field from 8 to 15 bits, allowing to target APIC IDs up 32768.
11962306a36Sopenharmony_ci */
12062306a36Sopenharmony_ci#define XEN_HVM_CPUID_EXT_DEST_ID      (1u << 5)
12162306a36Sopenharmony_ci/*
12262306a36Sopenharmony_ci * Per-vCPU event channel upcalls work correctly with physical IRQs
12362306a36Sopenharmony_ci * bound to event channels.
12462306a36Sopenharmony_ci */
12562306a36Sopenharmony_ci#define XEN_HVM_CPUID_UPCALL_VECTOR    (1u << 6)
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci/*
12862306a36Sopenharmony_ci * Leaf 6 (0x40000x05)
12962306a36Sopenharmony_ci * PV-specific parameters
13062306a36Sopenharmony_ci * Sub-leaf 0: EAX: max available sub-leaf
13162306a36Sopenharmony_ci * Sub-leaf 0: EBX: bits 0-7: max machine address width
13262306a36Sopenharmony_ci */
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci/* Max. address width in bits taking memory hotplug into account. */
13562306a36Sopenharmony_ci#define XEN_CPUID_MACHINE_ADDRESS_WIDTH_MASK (0xffu << 0)
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci#define XEN_CPUID_MAX_NUM_LEAVES 5
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
140