Skip to content

Commit 934ca9b

Browse files
committed
xen/arch/x86/cpu/intel.c: Report SMX and TXT capabilities
Report the SMX and TXT capabilitiesso that dom0 can query the Intel TXT support information using xl dmesg. Signed-off-by: Michał Żygowski <[email protected]>
1 parent a19bd1b commit 934ca9b

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

xen/arch/x86/cpu/intel.c

+44
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/i387.h>
1414
#include <mach_apic.h>
1515
#include <asm/hvm/support.h>
16+
#include <asm/intel_txt.h>
1617

1718
#include "cpu.h"
1819

@@ -525,6 +526,47 @@ static void intel_log_freq(const struct cpuinfo_x86 *c)
525526
printk("%u MHz\n", (factor * max_ratio + 50) / 100);
526527
}
527528

529+
/*
530+
* Print out the SMX and TXT capabilties, so that dom0 can determine if system
531+
* is DRTM capable
532+
*/
533+
static void intel_log_smx_txt(struct cpuinfo_x86 *c)
534+
{
535+
unsigned long cr4_val, getsec_caps;
536+
537+
/* Run only on BSP to report the SMX/TXT caps only once */
538+
if (smp_processor_id())
539+
return;
540+
541+
printk("CPU: SMX capability ");
542+
if (!test_bit(X86_FEATURE_SMX, &boot_cpu_data.x86_capability)) {
543+
printk("not supported\n");
544+
return;
545+
}
546+
printk("supported\n");
547+
548+
/* Can't run GETSEC without VMX and SMX */
549+
if (!test_bit(X86_FEATURE_VMX, &boot_cpu_data.x86_capability))
550+
return;
551+
552+
cr4_val = read_cr4();
553+
if (!(cr4_val & X86_CR4_SMXE))
554+
write_cr4(cr4_val | X86_CR4_SMXE);
555+
556+
asm volatile ("getsec\n"
557+
: "=a" (getsec_caps)
558+
: "a" (GETSEC_CAPABILITIES), "b" (0) :);
559+
560+
if (getsec_caps & GETSEC_CAP_TXT_CHIPSET)
561+
printk("Chipset supports TXT\n");
562+
else
563+
printk("Chipset does not support TXT\n");
564+
565+
if (!(cr4_val & X86_CR4_SMXE))
566+
write_cr4(cr4_val & ~X86_CR4_SMXE);
567+
568+
}
569+
528570
static void cf_check init_intel(struct cpuinfo_x86 *c)
529571
{
530572
/* Detect the extended topology information if available */
@@ -565,6 +607,8 @@ static void cf_check init_intel(struct cpuinfo_x86 *c)
565607
detect_ht(c);
566608
}
567609

610+
intel_log_smx_txt(c);
611+
568612
/* Work around errata */
569613
Intel_errata_workarounds(c);
570614

xen/arch/x86/include/asm/intel_txt.h

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
#define TXT_AP_BOOT_CS 0x0030
7979
#define TXT_AP_BOOT_DS 0x0038
8080

81+
/* EAX value for GETSEC leaf functions. Intel SDM: GETSEC[CAPABILITIES] */
82+
#define GETSEC_CAPABILITIES 0
83+
/* Intel SDM: GETSEC Capability Result Encoding */
84+
#define GETSEC_CAP_TXT_CHIPSET 1
85+
8186
#ifndef __ASSEMBLY__
8287

8388
extern char txt_ap_entry[];

0 commit comments

Comments
 (0)