[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v1 7/8] tpm: Guard irq related ops in case interrupts are disabled
From: |
Stefan Berger |
Subject: |
[PULL v1 7/8] tpm: Guard irq related ops in case interrupts are disabled |
Date: |
Thu, 25 Jun 2020 09:23:24 -0400 |
Check for irq_num having the value of TPM_IRQ_DISABLED before calling any
IRQ related functions or allowing the user to try to enable interrupts.
Explicitly allow the value of TPM_IRQ_DISABLED in irq_num.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Message-id: 20200617142305.1198672-8-stefanb@linux.vnet.ibm.com
---
hw/tpm/tpm_tis_common.c | 12 +++++++++++-
hw/tpm/tpm_tis_isa.c | 6 ++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/hw/tpm/tpm_tis_common.c b/hw/tpm/tpm_tis_common.c
index 93667e7788..8ecd11a38c 100644
--- a/hw/tpm/tpm_tis_common.c
+++ b/hw/tpm/tpm_tis_common.c
@@ -354,7 +354,11 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr
addr,
val = s->loc[locty].inte;
break;
case TPM_TIS_REG_INT_VECTOR:
- val = s->irq_num;
+ if (s->irq_num != TPM_IRQ_DISABLED) {
+ val = s->irq_num;
+ } else {
+ val = 0;
+ }
break;
case TPM_TIS_REG_INT_STATUS:
val = s->loc[locty].ints;
@@ -586,6 +590,9 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
if (s->active_locty != locty) {
break;
}
+ if (s->irq_num == TPM_IRQ_DISABLED) {
+ val &= ~TPM_TIS_INT_ENABLED;
+ }
s->loc[locty].inte &= mask;
s->loc[locty].inte |= (val & (TPM_TIS_INT_ENABLED |
@@ -596,6 +603,9 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
/* hard wired -- ignore */
break;
case TPM_TIS_REG_INT_STATUS:
+ if (s->irq_num == TPM_IRQ_DISABLED) {
+ break;
+ }
/* clearing of interrupt flags */
if (((val & TPM_TIS_INTERRUPTS_SUPPORTED)) &&
(s->loc[locty].ints & TPM_TIS_INTERRUPTS_SUPPORTED)) {
diff --git a/hw/tpm/tpm_tis_isa.c b/hw/tpm/tpm_tis_isa.c
index d00d49994d..11fec805d0 100644
--- a/hw/tpm/tpm_tis_isa.c
+++ b/hw/tpm/tpm_tis_isa.c
@@ -128,13 +128,15 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error
**errp)
error_setg(errp, "'tpmdev' property is required");
return;
}
- if (s->irq_num > 15) {
+ if (s->irq_num > 15 && s->irq_num != TPM_IRQ_DISABLED) {
error_setg(errp, "IRQ %d is outside valid range of 0 to 15",
s->irq_num);
return;
}
- isa_init_irq(ISA_DEVICE(dev), &s->irq, s->irq_num);
+ if (s->irq_num != TPM_IRQ_DISABLED) {
+ isa_init_irq(ISA_DEVICE(dev), &s->irq, s->irq_num);
+ }
memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
TPM_TIS_ADDR_BASE, &s->mmio);
--
2.24.1
- [PULL v1 0/8] Merge tpm 2020/06/25 v1, Stefan Berger, 2020/06/25
- [PULL v1 2/8] tpm: Extend TPMIfClass with get_irqnum() function, Stefan Berger, 2020/06/25
- [PULL v1 4/8] tpm: Split TPM_TIS_IRQ into TPM_TIS_ISA_IRQ and TPM_TIS_SYSBUS_IRQ, Stefan Berger, 2020/06/25
- [PULL v1 6/8] tests: Add updated DSDT, Stefan Berger, 2020/06/25
- [PULL v1 5/8] acpi: Enable TPM IRQ, Stefan Berger, 2020/06/25
- [PULL v1 3/8] tests: Temporarily ignore DSDT table differences, Stefan Berger, 2020/06/25
- [PULL v1 8/8] tpm: Disable interrupt support for TIS on sysbus, Stefan Berger, 2020/06/25
- [PULL v1 7/8] tpm: Guard irq related ops in case interrupts are disabled,
Stefan Berger <=
- [PULL v1 1/8] tpm_tis: Allow lowering of IRQ also when locality is not active, Stefan Berger, 2020/06/25
- Re: [PULL v1 0/8] Merge tpm 2020/06/25 v1, Stefan Berger, 2020/06/25