diff options
author | Stefan Berger <stefanb@linux.vnet.ibm.com> | 2018-03-28 15:39:17 -0400 |
---|---|---|
committer | Stefan Berger <stefanb@linux.vnet.ibm.com> | 2018-03-29 17:41:02 -0400 |
commit | 384cf1fc6494b590bb4fe8060d6271717bfb3f4b (patch) | |
tree | dcad3f11791e550b10be9bd263601135be9ab135 /hw/tpm | |
parent | 025bc9361960ba8a7ce8204a6128d716af0910fa (diff) |
tpm: CRB: Enforce locality is requested before processing buffer
Section 5.5.3.2.2 of the CRB specs states that use of the TPM
through the localty control method must first be requested,
otherwise the command will be dropped.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'hw/tpm')
-rw-r--r-- | hw/tpm/tpm_crb.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c index ee6c87e8db..a92dd50437 100644 --- a/hw/tpm/tpm_crb.c +++ b/hw/tpm/tpm_crb.c @@ -76,6 +76,8 @@ enum crb_cancel { CRB_CANCEL_INVOKE = BIT(0), }; +#define TPM_CRB_NO_LOCALITY 0xff + static uint64_t tpm_crb_mmio_read(void *opaque, hwaddr addr, unsigned size) { @@ -95,10 +97,19 @@ static uint64_t tpm_crb_mmio_read(void *opaque, hwaddr addr, return val; } +static uint8_t tpm_crb_get_active_locty(CRBState *s) +{ + if (!ARRAY_FIELD_EX32(s->regs, CRB_LOC_STATE, locAssigned)) { + return TPM_CRB_NO_LOCALITY; + } + return ARRAY_FIELD_EX32(s->regs, CRB_LOC_STATE, activeLocality); +} + static void tpm_crb_mmio_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { CRBState *s = CRB(opaque); + uint8_t locty = addr >> 12; trace_tpm_crb_mmio_write(addr, size, val); @@ -123,7 +134,8 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr, break; case A_CRB_CTRL_START: if (val == CRB_START_INVOKE && - !(s->regs[R_CRB_CTRL_START] & CRB_START_INVOKE)) { + !(s->regs[R_CRB_CTRL_START] & CRB_START_INVOKE) && + tpm_crb_get_active_locty(s) == locty) { void *mem = memory_region_get_ram_ptr(&s->cmdmem); s->regs[R_CRB_CTRL_START] |= CRB_START_INVOKE; |