tpm2-tss icon indicating copy to clipboard operation
tpm2-tss copied to clipboard

Failed to open device file /dev/tpmrm0

Open Bab95 opened this issue 1 year ago • 1 comments

I am facing this issue ERROR:tcti:src/tss2-tcti/tcti-device.c:440:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpmrm0: No such file or directory ERROR:tcti:src/tss2-tcti/tcti-device.c:440:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpmrm0: No such file or directory terminate called after throwing an instance of 'Tss2Exception' what(): tpm2-tss exception : message=Failed to initialize TCTI context, code=655370

tpmrm0 file should be present at /dev path but it's not which is causing this problem. Operating system is Linux (Sles 15.4)

TSS2_RC
Tss2_Tcti_Device_Init (
    TSS2_TCTI_CONTEXT *tctiContext,
    size_t *size,
    const char *conf)
{
    TSS2_TCTI_DEVICE_CONTEXT *tcti_dev;
    TSS2_TCTI_COMMON_CONTEXT *tcti_common;
    const char *dev_path = conf != NULL ? conf : TCTI_DEVICE_DEFAULT;

    if (tctiContext == NULL && size == NULL) {
        return TSS2_TCTI_RC_BAD_VALUE;
    } else if (tctiContext == NULL) {
        *size = sizeof (TSS2_TCTI_DEVICE_CONTEXT);
        return TSS2_RC_SUCCESS;
    }

    /* Init TCTI context */
    TSS2_TCTI_MAGIC (tctiContext) = TCTI_DEVICE_MAGIC;
    TSS2_TCTI_VERSION (tctiContext) = TCTI_VERSION;
    TSS2_TCTI_TRANSMIT (tctiContext) = tcti_device_transmit;
    TSS2_TCTI_RECEIVE (tctiContext) = tcti_device_receive;
    TSS2_TCTI_FINALIZE (tctiContext) = tcti_device_finalize;
    TSS2_TCTI_CANCEL (tctiContext) = tcti_device_cancel;
    TSS2_TCTI_GET_POLL_HANDLES (tctiContext) = tcti_device_get_poll_handles;
    TSS2_TCTI_SET_LOCALITY (tctiContext) = tcti_device_set_locality;
    TSS2_TCTI_MAKE_STICKY (tctiContext) = tcti_make_sticky_not_implemented;
    tcti_dev = tcti_device_context_cast (tctiContext);
    tcti_common = tcti_device_down_cast (tcti_dev);
    tcti_common->state = TCTI_STATE_TRANSMIT;
    memset (&tcti_common->header, 0, sizeof (tcti_common->header));
    tcti_common->locality = 3;

#ifdef __VXWORKS__
    tcti_dev->fd = open (dev_path, O_RDWR, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP));
#else
    tcti_dev->fd = open (dev_path, O_RDWR | O_NONBLOCK);
#endif
    if (tcti_dev->fd < 0) {
        LOG_ERROR ("Failed to open device file %s: %s",
                   dev_path, strerror (errno));
        return TSS2_TCTI_RC_IO_ERROR;
    }

    return TSS2_RC_SUCCESS;
}

problem seems be at TSS2_TCTI_RC_IO_ERROR .

what debug steps should i take further?

Bab95 avatar Jul 07 '23 07:07 Bab95

This is not a tpm2-tss issue. /dev/tpm0 and /dev/tpmrm0 are provided by your Linux kernel. /dev/tpm0 is the "vanilla" TPM while with /dev/tpmrm0, you're talking to the Resource Manager (which in turn talks to the TPM).

You want to make sure is that the kernel module tpm_tis is loaded:

lsmod

If not, load it:

modprobe tpm_tis

joholl avatar Jul 08 '23 08:07 joholl