[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 15/15] xen: tools: expose EPC in ACPI table
On physical machine EPC is exposed in ACPI table via "INT0E0C". Although EPC can be discovered by CPUID but Windows driver requires EPC to be exposed in ACPI table as well. This patch exposes EPC in ACPI table. Signed-off-by: Kai Huang <kai.huang@xxxxxxxxxxxxxxx> --- tools/firmware/hvmloader/util.c | 23 +++++++++++++++++++ tools/firmware/hvmloader/util.h | 3 +++ tools/libacpi/build.c | 3 +++ tools/libacpi/dsdt.asl | 49 ++++++++++++++++++++++++++++++++++++++++ tools/libacpi/dsdt_acpi_info.asl | 6 +++-- tools/libacpi/libacpi.h | 1 + tools/libxl/libxl_x86_acpi.c | 3 +++ 7 files changed, 86 insertions(+), 2 deletions(-) diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index db5f240bb9..4a1da2d63a 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -330,6 +330,15 @@ cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) : "0" (idx) ); } +void cpuid_count(uint32_t idx, uint32_t count, uint32_t *eax, + uint32_t *ebx, uint32_t *ecx, uint32_t *edx) +{ + asm volatile ( + "cpuid" + : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + : "0" (idx), "c" (count) ); +} + static const char hex_digits[] = "0123456789abcdef"; /* Write a two-character hex representation of 'byte' to digits[]. @@ -888,6 +897,18 @@ static uint8_t acpi_lapic_id(unsigned cpu) return LAPIC_ID(cpu); } +static void get_epc_info(struct acpi_config *config) +{ + uint32_t eax, ebx, ecx, edx; + + cpuid_count(0x12, 0x2, &eax, &ebx, &ecx, &edx); + + config->epc_base = (((uint64_t)(ebx & 0xfffff)) << 32) | + (uint64_t)(eax & 0xfffff000); + config->epc_size = (((uint64_t)(edx & 0xfffff)) << 32) | + (uint64_t)(ecx & 0xfffff000); +} + void hvmloader_acpi_build_tables(struct acpi_config *config, unsigned int physical) { @@ -920,6 +941,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config, config->pci_hi_len = pci_hi_mem_end - pci_hi_mem_start; } + get_epc_info(config); + s = xenstore_read("platform/generation-id", "0:0"); if ( s ) { diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 6062f0b8cf..deac0abb86 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -112,6 +112,9 @@ int hpet_exists(unsigned long hpet_base); void cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); +void cpuid_count(uint32_t idx, uint32_t count, uint32_t *eax, + uint32_t *ebx, uint32_t *ecx, uint32_t *edx); + /* Read the TSC register. */ static inline uint64_t rdtsc(void) { diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c index f9881c9604..9d64856e26 100644 --- a/tools/libacpi/build.c +++ b/tools/libacpi/build.c @@ -54,6 +54,7 @@ struct acpi_info { uint32_t madt_lapic0_addr; /* 16 - Address of first MADT LAPIC struct */ uint32_t vm_gid_addr; /* 20 - Address of VM generation id buffer */ uint64_t pci_hi_min, pci_hi_len; /* 24, 32 - PCI I/O hole boundaries */ + uint64_t epc_min, epc_len; /* 40, 48 - EPC region */ }; static void set_checksum( @@ -535,6 +536,8 @@ int acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config) acpi_info->pci_hi_min = config->pci_hi_start; acpi_info->pci_hi_len = config->pci_hi_len; } + acpi_info->epc_min = config->epc_base; + acpi_info->epc_len = config->epc_size; /* * Fill in high-memory data structures, starting at @buf. diff --git a/tools/libacpi/dsdt.asl b/tools/libacpi/dsdt.asl index fa8ff317b2..25ce196028 100644 --- a/tools/libacpi/dsdt.asl +++ b/tools/libacpi/dsdt.asl @@ -441,6 +441,55 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0) } } } + + Device (EPC) + { + Name (_HID, EisaId ("INT0E0C")) + Name (_STR, Unicode ("Enclave Page Cache 1.5")) + Name (_MLS, Package (0x01) + { + Package (0x02) + { + "en", + Unicode ("Enclave Page Cache 1.5") + } + }) + Name (RBUF, ResourceTemplate () + { + QWordMemory (ResourceConsumer, PosDecode, MinFixed, MaxFixed, + Cacheable, ReadWrite, + 0x0000000000000000, // Granularity + 0x0000000000000000, // Range Minimum + 0x0000000000000000, // Range Maximum + 0x0000000000000000, // Translation Offset + 0x0000000000000001, // Length + ,, _Y03, + AddressRangeMemory, TypeStatic) + }) + + Method(_CRS, 0, NotSerialized) // _CRS: Current Resource Settings + { + CreateQwordField (RBUF, \_SB.EPC._Y03._MIN, EMIN) // _MIN: Minimuum Base Address + CreateQwordField (RBUF, \_SB.EPC._Y03._MAX, EMAX) // _MIN: Maximum Base Address + CreateQwordField (RBUF, \_SB.EPC._Y03._LEN, ELEN) // _LEN: Length + Store(\_SB.EMIN, EMIN) + Store(\_SB.ELEN, ELEN) + Add(EMIN, ELEN, EMAX) + Subtract(EMAX, One, EMAX) + + Return (RBUF) + } + + Method(_STA, 0, NotSerialized) // _STA: Status + { + IF ((\_SB.ELEN != Zero)) + { + Return (0x0F) + } + + Return (Zero) + } + } } /* _S3 and _S4 are in separate SSDTs */ Name (\_S5, Package (0x04) { diff --git a/tools/libacpi/dsdt_acpi_info.asl b/tools/libacpi/dsdt_acpi_info.asl index 0136dce55c..ac6b14f82f 100644 --- a/tools/libacpi/dsdt_acpi_info.asl +++ b/tools/libacpi/dsdt_acpi_info.asl @@ -5,7 +5,7 @@ * BIOS region must match struct acpi_info in build.c and * be located at ACPI_INFO_PHYSICAL_ADDRESS = 0xFC000000 */ - OperationRegion(BIOS, SystemMemory, 0xFC000000, 40) + OperationRegion(BIOS, SystemMemory, 0xFC000000, 56) Field(BIOS, ByteAcc, NoLock, Preserve) { UAR1, 1, UAR2, 1, @@ -21,6 +21,8 @@ LMIN, 32, HMIN, 32, LLEN, 32, - HLEN, 32 + HLEN, 32, + EMIN, 64, + ELEN, 64, } } diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h index 2ed1ecfc8e..5645e0866b 100644 --- a/tools/libacpi/libacpi.h +++ b/tools/libacpi/libacpi.h @@ -63,6 +63,7 @@ struct acpi_config { /* PCI I/O hole */ uint32_t pci_start, pci_len; uint64_t pci_hi_start, pci_hi_len; + uint64_t epc_base, epc_size; uint32_t table_flags; uint8_t acpi_revision; diff --git a/tools/libxl/libxl_x86_acpi.c b/tools/libxl/libxl_x86_acpi.c index c0a6e321ec..0d62a76590 100644 --- a/tools/libxl/libxl_x86_acpi.c +++ b/tools/libxl/libxl_x86_acpi.c @@ -156,6 +156,9 @@ static int init_acpi_config(libxl__gc *gc, config->lapic_id = acpi_lapic_id; config->acpi_revision = 5; + config->epc_base = b_info->u.hvm.sgx.epcbase; + config->epc_size = (b_info->u.hvm.sgx.epckb << 10); + rc = 0; out: return rc; -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |