tpm: Rework TPM interface shutdown support
The 16bit BIOS interface should only shutdown on request from that
interface - errors from the tcp or acpi log setup should not shutdown
the interface. (Errors from those functions will cause the TPM to be
in a "not working" state which will cause all the 16bit interface
functions to fail.)
Centralize the checking for the interface shutdown condition in
tpm_interrupt_handler32().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 9e075ee..1691d88 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -67,7 +67,6 @@
****************************************************************/
typedef struct {
- u8 if_shutdown:1;
struct tcpa_descriptor_rev2 *tcpa;
/* length of the TCPA log buffer */
@@ -90,12 +89,6 @@
typedef u8 tpm_ppi_code;
-static u32
-is_preboot_if_shutdown(void)
-{
- return tpm_state.if_shutdown;
-}
-
/****************************************************************
* ACPI TCPA table interface
@@ -149,8 +142,6 @@
if (rsdp)
tcpa = find_tcpa_by_rsdp(rsdp);
- else
- tpm_state.if_shutdown = 1;
if (!rsdp)
dprintf(DEBUG_tcg,
@@ -585,10 +576,8 @@
tpm_acpi_init(void)
{
int ret = tpmhw_probe();
- if (ret) {
- tpm_state.if_shutdown = 1;
+ if (ret)
return;
- }
TPM_working = 1;
reset_acpi_log();
@@ -771,6 +760,8 @@
* BIOS interface
****************************************************************/
+u8 TPM_interface_shutdown VARLOW;
+
static inline void *input_buf32(struct bregs *regs)
{
return MAKE_FLATPTR(regs->es, regs->di);
@@ -793,11 +784,6 @@
struct pcpes *pcpes;
u32 pcrindex;
- if (is_preboot_if_shutdown() != 0) {
- rc = TCG_INTERFACE_SHUTDOWN;
- goto err_exit;
- }
-
/* short or long version? */
switch (hleei_s->ipblength) {
case sizeof(struct hleei_short):
@@ -850,12 +836,6 @@
pass_through_to_tpm_int(struct pttti *pttti, struct pttto *pttto)
{
u32 rc = 0;
-
- if (is_preboot_if_shutdown()) {
- rc = TCG_INTERFACE_SHUTDOWN;
- goto err_exit;
- }
-
struct tpm_req_header *trh = (void*)pttti->tpmopin;
if (pttti->ipblength < sizeof(struct pttti) + sizeof(trh)
@@ -886,15 +866,8 @@
static u32
shutdown_preboot_interface(void)
{
- u32 rc = 0;
-
- if (!is_preboot_if_shutdown()) {
- tpm_state.if_shutdown = 1;
- } else {
- rc = TCG_INTERFACE_SHUTDOWN;
- }
-
- return rc;
+ TPM_interface_shutdown = 1;
+ return 0;
}
static u32
@@ -904,11 +877,6 @@
u16 size;
struct pcpes *pcpes;
- if (is_preboot_if_shutdown() != 0) {
- rc = TCG_INTERFACE_SHUTDOWN;
- goto err_exit;
- }
-
size = hlei->ipblength;
if (size != sizeof(*hlei)) {
rc = TCG_INVALID_INPUT_PARA;
@@ -946,9 +914,6 @@
static u32
hash_all_int(const struct hai *hai, u8 *hash)
{
- if (is_preboot_if_shutdown() != 0)
- return TCG_INTERFACE_SHUTDOWN;
-
if (hai->ipblength != sizeof(struct hai) ||
hai->hashdataptr == 0 ||
hai->hashdatalen == 0 ||
@@ -961,18 +926,10 @@
static u32
tss_int(struct ti *ti, struct to *to)
{
- u32 rc = 0;
-
- if (is_preboot_if_shutdown() == 0) {
- rc = TCG_PC_UNSUPPORTED;
- } else {
- rc = TCG_INTERFACE_SHUTDOWN;
- }
-
to->opblength = sizeof(struct to);
to->reserved = 0;
- return rc;
+ return TCG_PC_UNSUPPORTED;
}
static u32
@@ -988,9 +945,6 @@
.eventdatasize = sizeof(info),
};
- if (is_preboot_if_shutdown() != 0)
- return TCG_INTERFACE_SHUTDOWN;
-
tpm_fill_hash(&pcpes, buffer, length);
u32 rc = tpm_log_extend_event(&pcpes, &info);
if (rc == 0)
@@ -1007,6 +961,11 @@
set_cf(regs, 0);
+ if (TPM_interface_shutdown && regs->al) {
+ regs->eax = TCG_INTERFACE_SHUTDOWN;
+ return;
+ }
+
switch ((enum irq_ids)regs->al) {
case TCG_StatusCheck:
if (!tpmhw_is_present()) {