提交 384cf1fc 编写于 作者: S Stefan Berger

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: NStefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
上级 025bc936
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册