aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-03-30 23:05:19 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-03-30 23:05:19 +0100
commiteae3aace85eabdeb610c154914344d52f13b3540 (patch)
tree7b603763aac757b25b3dc497b204c72210ce8762 /hw
parent4cd327ded7337c418da114c184cf5868fd980ab4 (diff)
parent4d0d1c077e5622da95fd0f6a8e7efb72e0f222b4 (diff)
downloadqemu-eae3aace85eabdeb610c154914344d52f13b3540.zip
qemu-eae3aace85eabdeb610c154914344d52f13b3540.tar.gz
qemu-eae3aace85eabdeb610c154914344d52f13b3540.tar.bz2
Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2018-03-29-1' into staging
Merge tpm 2018/03/29 v1 # gpg: Signature made Fri 30 Mar 2018 01:04:47 BST # gpg: using RSA key 75AD65802A0B4211 # gpg: Good signature from "Stefan Berger <stefanb@linux.vnet.ibm.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: B818 B9CA DF90 89C2 D5CE C66B 75AD 6580 2A0B 4211 * remotes/stefanberger/tags/pull-tpm-2018-03-29-1: tests: Tests more flags of the CRB interface tpm: CRB: Enforce locality is requested before processing buffer tpm: CRB: Reset Granted flag when relinquishing locality tpm: CRB: set the Idle flag by default Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/tpm/tpm_crb.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index ef8b80e..a92dd50 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;
@@ -145,6 +157,8 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
case CRB_LOC_CTRL_RELINQUISH:
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
locAssigned, 0);
+ ARRAY_FIELD_DP32(s->regs, CRB_LOC_STS,
+ Granted, 0);
break;
case CRB_LOC_CTRL_REQUEST_ACCESS:
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STS,
@@ -220,6 +234,8 @@ static void tpm_crb_reset(void *dev)
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
tpmRegValidSts, 1);
+ ARRAY_FIELD_DP32(s->regs, CRB_CTRL_STS,
+ tpmIdle, 1);
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
InterfaceType, CRB_INTF_TYPE_CRB_ACTIVE);
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,