• Mario Limonciello's avatar
    tpm: disable hwrng for fTPM on some AMD designs · f1324bbc
    Mario Limonciello authored
    AMD has issued an advisory indicating that having fTPM enabled in
    BIOS can cause "stuttering" in the OS.  This issue has been fixed
    in newer versions of the fTPM firmware, but it's up to system
    designers to decide whether to distribute it.
    
    This issue has existed for a while, but is more prevalent starting
    with kernel 6.1 because commit b006c439 ("hwrng: core - start
    hwrng kthread also for untrusted sources") started to use the fTPM
    for hwrng by default. However, all uses of /dev/hwrng result in
    unacceptable stuttering.
    
    So, simply disable registration of the defective hwrng when detecting
    these faulty fTPM versions.  As this is caused by faulty firmware, it
    is plausible that such a problem could also be reproduced by other TPM
    interactions, but this hasn't been shown by any user's testing or reports.
    
    It is hypothesized to be triggered more frequently by the use of the RNG
    because userspace software will fetch random numbers regularly.
    
    Intentionally continue to register other TPM functionality so that users
    that rely upon PCR measurements or any storage of data will still have
    access to it.  If it's found later that another TPM functionality is
    exacerbating this problem a module parameter it can be turned off entirely
    and a module parameter can be introduced to allow users who rely upon
    fTPM functionality to turn it on even though this problem is present.
    
    Link: https://www.amd.com/en/support/kb/faq/pa-410
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216989
    Link: https://lore.kernel.org/all/20230209153120.261904-1-Jason@zx2c4.com/
    Fixes: b006c439 ("hwrng: core - start hwrng kthread also for untrusted sources")
    Cc: stable@vger.kernel.org
    Cc: Jarkko Sakkinen <jarkko@kernel.org>
    Cc: Thorsten Leemhuis <regressions@leemhuis.info>
    Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
    Tested-by: reach622@mailcuk.com
    Tested-by: default avatarBell <1138267643@qq.com>
    Co-developed-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
    Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
    f1324bbc
tpm.h 9.79 KB