summaryrefslogtreecommitdiff
path: root/src/security/intel/txt/txtlib.c
diff options
context:
space:
mode:
authorSubrata Banik <subratabanik@google.com>2022-12-31 14:43:57 +0530
committerSubrata Banik <subratabanik@google.com>2023-01-09 04:30:39 +0000
commitad87a82ca7d960ee696dd57c013d75609212eb66 (patch)
treec1eb27873647b8818e95c3273af712eee474d9a3 /src/security/intel/txt/txtlib.c
parent93f12985e6b75f8a7b576a5a6b795ca3a8823395 (diff)
security/intel/txt: Add helper function to disable TXT
Add a function to disable TXT as per TXT BIOS spec Section 6.2.5. AP firmware can disable TXT if TXT fails or TPM is already enabled. On platforms with TXT disabled, the memory can be unlocked using MSR 0x2e6. TEST=Able to perform disable_txt on SoC SKUs with TXT enabled. Signed-off-by: Subrata Banik <subratabanik@google.com> Change-Id: I27f613428e82a1dd924172eab853d2ce9c32b473 Reviewed-on: https://review.coreboot.org/c/coreboot/+/71574 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tarun Tuli <taruntuli@google.com> Reviewed-by: Sridhar Siricilla <sridhar.siricilla@intel.com> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Diffstat (limited to 'src/security/intel/txt/txtlib.c')
-rw-r--r--src/security/intel/txt/txtlib.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/security/intel/txt/txtlib.c b/src/security/intel/txt/txtlib.c
index 3ec2322f77..5478206ee2 100644
--- a/src/security/intel/txt/txtlib.c
+++ b/src/security/intel/txt/txtlib.c
@@ -44,3 +44,29 @@ bool is_txt_cpu(void)
return (ecx & (CPUID_SMX | CPUID_VMX)) == (CPUID_SMX | CPUID_VMX);
}
+
+static void unlock_txt_memory(void)
+{
+ msr_t msrval = {0};
+
+ wrmsr(IA32_LT_UNLOCK_MEMORY, msrval);
+}
+
+void disable_intel_txt(void)
+{
+ /* Return if the CPU doesn't support TXT */
+ if (!is_txt_cpu()) {
+ printk(BIOS_DEBUG, "Abort disabling TXT, as CPU is not TXT capable.\n");
+ return;
+ }
+
+ /*
+ * Memory is supposed to be locked if system is TXT capable
+ * As per TXT BIOS spec Section 6.2.5 unlock memory
+ * when security (TPM) is set and TXT is not enabled.
+ */
+ if (!is_establishment_bit_asserted()) {
+ unlock_txt_memory();
+ printk(BIOS_INFO, "TXT disabled successfully - Unlocked memory\n");
+ }
+}