Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp809631rwr; Thu, 27 Apr 2023 08:23:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZArprfMwefl7X+5hJ2fHl0o/+0cZ+apTRsNV4Ii7Y+hCywOaL/yPd2DCoAdkY4WtHp3GV X-Received: by 2002:a05:6a20:6a26:b0:f6:9492:93e9 with SMTP id p38-20020a056a206a2600b000f6949293e9mr2434790pzk.4.1682609033280; Thu, 27 Apr 2023 08:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682609033; cv=none; d=google.com; s=arc-20160816; b=dMbaQnL9Wb2xQF47ZHNrgo0qxm6guxgSJNM24JP7J6HSaECGJyZBCkP0pvhmn+Y4oM 0o0FXCVvJNLE1o15JnIj3lseK0YGiiGlNIoXnKple58kRkhNoBpAPiY0shBhy2/0pYuV IA0U9hhPO9PpTTv9t3ePsrONOtO7cBGmf/F7UgSrTjGQ67ZApCHtH9QpzFx0Xp6aZnWH uowsRzjsPhB0c99bRXKIZyhln2NAWMOdLzqNf3275ZofXufz+RsJwvBKMTdrcRiNDFsJ /iwEST0o7CtfAf7QFCPeYYyNJUTaF8jiGuzeyitzYhzZrdDAMYjuQGIKygFTv6HAghw6 QS7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YEofZFRl2d8BOu5BwJ07xScSj7ivyiDT35/EYFvK1+Y=; b=IKNgPdYO/6DcjPUoL3GPdPBgLFm3VV5ObFS3ddnPeBaE9dhUJA4s3POqqoSUZv53HH fk+WpTvhZqWV9hmP+XmIGZ3InI+eVFc7nJDhYbjr2Ems5LjiJ+Gp/SiVWqH/2O0bdljE 0E2CWSfBz48p5t6rmDIxG+MV30AP65fp2CV/aE9eHyYM95opj9ZqZfbWg6UTXkvUD3Pg eRb1SUus1Svf4AO8dA/GTNSrQ8TKkgXb0PKX3j6jGzNuiC5iWGRXqkHdzpUURFJUtieY t4/FQ0H4FMcU3jLcLE4rFthyvmdAMV1Yn7r/+j5RujFc1/jkRLHMb8z1EN+xkSR1qQa8 +HYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N+QDGKYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a17090a670700b00249720507d9si15280216pjj.61.2023.04.27.08.23.40; Thu, 27 Apr 2023 08:23:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N+QDGKYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244135AbjD0PMv (ORCPT + 99 others); Thu, 27 Apr 2023 11:12:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243558AbjD0PMu (ORCPT ); Thu, 27 Apr 2023 11:12:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A68535A5 for ; Thu, 27 Apr 2023 08:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682608322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YEofZFRl2d8BOu5BwJ07xScSj7ivyiDT35/EYFvK1+Y=; b=N+QDGKYXX/XQLcYYWijDTvnntFSLjDAKRLY4KEVcBgk8tIXIzcrGOGS154ituyCtJbA4fd TeHQCH/UEgiIgEgHh4IN2WpYW018QN/kB7eEvHvhW74nLrRzBcdRlSOLyGh7vJ0/Y64XBE XGPutriNLREmsr9nLWxNukV+XVKhPVE= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-475-fEZROwSbM4OHbLjjicyaYg-1; Thu, 27 Apr 2023 11:11:46 -0400 X-MC-Unique: fEZROwSbM4OHbLjjicyaYg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-74df5c5fd00so672362785a.3 for ; Thu, 27 Apr 2023 08:11:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682608303; x=1685200303; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YEofZFRl2d8BOu5BwJ07xScSj7ivyiDT35/EYFvK1+Y=; b=Oqanz3BAKeBAGl0RjPZUi8qCpwnL1gZJODpvC4EKBZql/9w6zlDst3NWXK6FX+gdYn WLjfe94kBorxOPEVEYvokvvmAKxHs1Ma5x9nf5SrwU/0S6W8+frsx3CnapVGKL2AIn5o iMTsjwuOCbcMe2bzFidJCMxR5fGYI/UcA2JBWE+bvPQkZEo7l5NGq9zxSeUzSG9M4xZU Mte2DTssYCXjbFXl1qQPn7bO/JUbzqiIKEcCnxnAQQgc1p+RI23Ly+e1aypQvGUgk9Gx d3uayfZ1PXrEZfnhNf2ALduncjSq5+/Zx8gFTK6crpinyygEc3lOEAxMksRtOmDpmExO 4hzA== X-Gm-Message-State: AC+VfDwVcEF9SjxhvynWn9ie92eteXJud35R/KLWmZ/NcahIqEjXb4s4 njNgq6ptpqC4dQgTMpDinGj/f5Pdm6gZGpN9k1O9K2lH9csZ60GlSByylCUzk0lG9eZZw2Gj3QT /WQ8rNNhmc0qbXJLh17AR3iwf X-Received: by 2002:a05:622a:46:b0:3ef:2db1:6e75 with SMTP id y6-20020a05622a004600b003ef2db16e75mr3419075qtw.24.1682608303206; Thu, 27 Apr 2023 08:11:43 -0700 (PDT) X-Received: by 2002:a05:622a:46:b0:3ef:2db1:6e75 with SMTP id y6-20020a05622a004600b003ef2db16e75mr3419054qtw.24.1682608302970; Thu, 27 Apr 2023 08:11:42 -0700 (PDT) Received: from localhost (ip98-179-76-75.ph.ph.cox.net. [98.179.76.75]) by smtp.gmail.com with ESMTPSA id t10-20020a05622a148a00b003eec85171d6sm6235196qtx.61.2023.04.27.08.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 08:11:42 -0700 (PDT) Date: Thu, 27 Apr 2023 08:11:40 -0700 From: Jerry Snitselaar To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Stefan Berger , James Bottomley , stable@vger.kernel.org, "Jason A . Donenfeld" Subject: Re: [PATCH 1/2] tpm_tis: Use tpm_chip_{start,stop} decoration inside tpm_tis_resume Message-ID: <5qxby65cn22wolrlm4xemxfpfxyjgwjchhoev45egiwaubrqdc@f2ufxypkhnjt> References: <20230426172928.3963287-1-jarkko@kernel.org> <20230426172928.3963287-2-jarkko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230426172928.3963287-2-jarkko@kernel.org> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 26, 2023 at 08:29:27PM +0300, Jarkko Sakkinen wrote: > Before sending a TPM command, CLKRUN protocol must be disabled. This is not > done in the case of tpm1_do_selftest() call site inside tpm_tis_resume(). > > Address this by decorating the calls with tpm_chip_{start,stop}, which arm > and disarm the TPM chip for transmission, and take care of disabling and > re-enabling CLKRUN, among other things. > > Cc: stable@vger.kernel.org > Reported-by: Jason A. Donenfeld > Link: https://lore.kernel.org/linux-integrity/CS68AWILHXS4.3M36M1EKZLUMS@suppilovahvero/ > Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()") > Signed-off-by: Jarkko Sakkinen > --- > drivers/char/tpm/tpm_tis_core.c | 43 +++++++++++++++------------------ > 1 file changed, 19 insertions(+), 24 deletions(-) Reviewed-by: Jerry Snitselaar > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index c2421162cf34..73707026e358 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -1209,25 +1209,20 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip) > u32 intmask; > int rc; > > - if (chip->ops->clk_enable != NULL) > - chip->ops->clk_enable(chip, true); > - > - /* reenable interrupts that device may have lost or > - * BIOS/firmware may have disabled > + /* > + * Re-enable interrupts that device may have lost or BIOS/firmware may > + * have disabled. > */ > rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), priv->irq); > - if (rc < 0) > - goto out; > + if (rc < 0) { > + dev_err(&chip->dev, "Setting IRQ failed.\n"); > + return; > + } > > intmask = priv->int_mask | TPM_GLOBAL_INT_ENABLE; > - > - tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > - > -out: > - if (chip->ops->clk_enable != NULL) > - chip->ops->clk_enable(chip, false); > - > - return; > + rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); > + if (rc < 0) > + dev_err(&chip->dev, "Enabling interrupts failed.\n"); > } > > int tpm_tis_resume(struct device *dev) > @@ -1235,27 +1230,27 @@ int tpm_tis_resume(struct device *dev) > struct tpm_chip *chip = dev_get_drvdata(dev); > int ret; > > - ret = tpm_tis_request_locality(chip, 0); > - if (ret < 0) > + ret = tpm_chip_start(chip); > + if (ret) > return ret; > > if (chip->flags & TPM_CHIP_FLAG_IRQ) > tpm_tis_reenable_interrupts(chip); > > - ret = tpm_pm_resume(dev); > - if (ret) > - goto out; > - > /* > * TPM 1.2 requires self-test on resume. This function actually returns > * an error code but for unknown reason it isn't handled. > */ > if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) > tpm1_do_selftest(chip); > -out: > - tpm_tis_relinquish_locality(chip, 0); > > - return ret; > + tpm_chip_stop(chip); > + > + ret = tpm_pm_resume(dev); > + if (ret) > + return ret; > + > + return 0; > } > EXPORT_SYMBOL_GPL(tpm_tis_resume); > #endif > -- > 2.39.2 >