From patchwork Fri Jun 8 06:54:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Collard X-Patchwork-Id: 10453893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81C19601D4 for ; Fri, 8 Jun 2018 06:54:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 702C72847E for ; Fri, 8 Jun 2018 06:54:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6322928755; Fri, 8 Jun 2018 06:54:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21CCD2847E for ; Fri, 8 Jun 2018 06:54:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751138AbeFHGyo (ORCPT ); Fri, 8 Jun 2018 02:54:44 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:36855 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbeFHGyo (ORCPT ); Fri, 8 Jun 2018 02:54:44 -0400 Received: by mail-pl0-f68.google.com with SMTP id a7-v6so5225956plp.3 for ; Thu, 07 Jun 2018 23:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=HS95F6AmXx6dReOUr/RBhtRv3IaYyjkllBloByxiaTY=; b=T1VorLAU19R2I2IF77k1nR4ImZrzkQiMqjiklGBu0bdGw1OTh1Jv5VIT2lUPPs9ijp neCo/akjl8EnblEGKC2xr5iGtS/ZrlRAjdhdBYdQ5Z/cdG5SbL48Bg/gUQ9PO+x8T2fR 2wDJcVHC+ibRXgaFMrtMBylM++D8VfdEDsaNs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HS95F6AmXx6dReOUr/RBhtRv3IaYyjkllBloByxiaTY=; b=RL9ycwmnqUWRVETfUzkYtHZhUWl+Zh2J2qJguDBUAxSOU4Ei2Ob5GXEfzHHNEwirP9 vlQArMewmlAzAN7vxsFBXBscZ03VAWieWA4xWcSb5cb95s7plGCXAApwCTxCWFDp/5zG d8WT0Zzu4mIbqv5/T6XNAXSL7QfqiXzRtCvF+cal5vFNnFjYqz8iXyEVD3OTlLkHVB2/ LupEhskEsGBYcPU+Ism26qjadPTIg7m4QlmW+ympjRKR0n6V8GnXoN8eXoNqSdb6/tq8 zQWTKpyfb7upjX6y8vyAJljbIXF8G5YJTxcSUM7wRiiRduNHLmNXlywGrAhBpE+Vh99T l7LA== X-Gm-Message-State: APt69E1zZWYRcRb2bWipLrQBX0BUHKIsKZNoQEt8ZJ0WG6vZQqDvpBHn HxVreOyAf0C61MYRDKPo009RuE1EjwM= X-Google-Smtp-Source: ADUXVKKXSnhZo2nGSyGcnIMHhGxI2XNzZEo8dgL6qBG0lU4RB66BSEznuwgYJcTeScTl9Vo9DvreEQ== X-Received: by 2002:a17:902:aa48:: with SMTP id c8-v6mr5301951plr.132.1528440883598; Thu, 07 Jun 2018 23:54:43 -0700 (PDT) Received: from excession.tpe.corp.google.com ([2401:fa00:1:10:3987:9bf6:3352:7574]) by smtp.gmail.com with ESMTPSA id c27-v6sm63287516pfl.63.2018.06.07.23.54.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jun 2018 23:54:43 -0700 (PDT) From: Louis Collard To: linux-integrity@vger.kernel.org Cc: Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, apronin@chromium.org Subject: [PATCH] tpm: Add module parameter for hwrng quality. Date: Fri, 8 Jun 2018 14:54:38 +0800 Message-Id: <20180608065438.110109-1-louiscollard@chromium.org> X-Mailer: git-send-email 2.13.5 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is now possible for drivers to easily specify a hwrng quality, however most do not currently do this, and in cases where they do, it may be desirable to override the driver-specified value with a user-specified one. This patch adds a parameter to set or override the hwrng quality. Signed-off-by: Louis Collard --- drivers/char/tpm/tpm-chip.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 0a62c19937b6..4def49cfc634 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -33,6 +33,11 @@ DEFINE_IDR(dev_nums_idr); static DEFINE_MUTEX(idr_lock); +static short override_rng_quality = -1; +module_param(override_rng_quality, short, 0644); +MODULE_PARM_DESC(override_rng_quality, + "tpm-rng quality (overrides values provided by drivers)"); + struct class *tpm_class; struct class *tpmrm_class; dev_t tpm_devt; @@ -409,6 +414,13 @@ static int tpm_add_hwrng(struct tpm_chip *chip) "tpm-rng-%d", chip->dev_num); chip->hwrng.name = chip->hwrng_name; chip->hwrng.read = tpm_hwrng_read; + if (override_rng_quality > -1) { + dev_info(&chip->dev, + "Overriding hwrng quality for %s: driver default=%d, override=%d", + chip->hwrng.name, chip->hwrng.quality, + override_rng_quality); + chip->hwrng.quality = override_rng_quality; + } return hwrng_register(&chip->hwrng); }