Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3089062pxb; Sun, 31 Jan 2021 03:59:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsNVTpefHJjaivPfwqXmH+WWJR2xlAq90IceOGBMdFBXF3M/ZlRmZqTWDSzxwzwO29R+K4 X-Received: by 2002:aa7:cfda:: with SMTP id r26mr13638672edy.142.1612094355185; Sun, 31 Jan 2021 03:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612094355; cv=none; d=google.com; s=arc-20160816; b=CkpCLQ3DKWmwa5ZalBTM9//nUIWITatkZnGaD4Qq0629S/wV6zl++tEHfZyoi5/e01 BjusunbCBC8bXRaBuF83Zpf+4O/Pb3ezl1yJzozIdNHI6sjmvOu28zdwBsE/f1dcJtRK PW2yedlaabnEO4Lr5zhDSI8FtqCBXVVM1L9mz/+r9gAxfwDElcGzJMt5K/FMVzGPnNRf ENxzgAmo3V12gQixoMP5zcc22Y2NMv3Uj6n8/xIcbnufT5nN9LW7PFCsE7l/kW5vBXiZ CoIJtP7XlPDrSS348gAteRNOqorBreeg0uF/Dko/cNOJywb61de13m32sLtDyf/PJPlo +Xzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:user-agent:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=lWSbKlXFJHVLuji5QVsSUpiDiCJsPjIE8p8Bv8eSr/c=; b=kuHN3EWKZueFNKVvBMdqRa8m5O0xGET9IMnZlNa55/6D2H+RwEg1oP4ge90vDHInsA SJ3A4XWnRwI+U9sgSlzmr1GlfsHRtwIgrnDvOqUG67AXBuZGXZ7wiAP1H4PxpdoeNV0F I/noRMUQFrUFnjlzyZTfo/QpazWSIBwVqXsP3xxWL07Grf82wEeAGrF9CQNftajRgcm+ yZBHG2d5aSMOlGvv0cNw2YQca+shBkOgS41q8ZszYavsmJ5iv0Q5eDxIsJZa9mC8NzGy d06s1cMNWiPwFzaRv60wuYiifKf+rxP145nP23kfKgYYkPUdELpOvBmpdunAAhAoKYzz ESjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gouders.net header.s=gnet header.b=DY4M9cBc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a72si9300699edf.380.2021.01.31.03.58.49; Sun, 31 Jan 2021 03:59:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gouders.net header.s=gnet header.b=DY4M9cBc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231549AbhAaL47 (ORCPT + 99 others); Sun, 31 Jan 2021 06:56:59 -0500 Received: from services.gouders.net ([141.101.32.176]:33274 "EHLO services.gouders.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230517AbhAaKR3 (ORCPT ); Sun, 31 Jan 2021 05:17:29 -0500 X-Greylist: delayed 1124 seconds by postgrey-1.27 at vger.kernel.org; Sun, 31 Jan 2021 05:17:27 EST Received: from localhost (ltea-047-066-000-239.pools.arcor-ip.net [47.66.0.239]) (authenticated bits=0) by services.gouders.net (8.14.8/8.14.8) with ESMTP id 10V9ifno020651 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK); Sun, 31 Jan 2021 10:44:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gouders.net; s=gnet; t=1612086283; bh=vLKM33XF2MpuIYW7z8Tq/AxC1zWZT620ykbKLfQVP2s=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=DY4M9cBcyaOrE5pu8gzsi6lLsDdG3KNHZCr1onc2+4iGjO4t/SPhWT5aD6yJ6x35K Rxk3J8YjjufGblbS5Dh7llbStZXiu+0U7frMJrAFcVxVoDWvcV7SEkkxdWrn9gc8sU 2YvYGkT+tMQdTrGGAAWQWAnN6660vTjE+S0P8/m0= From: Dirk Gouders To: Jarkko Sakkinen Cc: Lukasz Majczak , Guenter Roeck , James Bottomley , Tj , Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Radoslaw Biernacki , Marcin Wojtas , Alex Levin Subject: Re: [PATCH v2] tpm_tis: Add missing tpm_request/relinquish_locality calls In-Reply-To: <464454f440df67d3470e67ff0386bbc306d07dac.camel@kernel.org> (Jarkko Sakkinen's message of "Sat, 30 Jan 2021 22:40:40 +0200") References: <20210123014247.989368-1-lma@semihalf.com> <20210128130753.1283534-1-lma@semihalf.com> <464454f440df67d3470e67ff0386bbc306d07dac.camel@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Date: Sun, 31 Jan 2021 10:43:05 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jarkko Sakkinen writes: > On Thu, 2021-01-28 at 14:07 +0100, Lukasz Majczak wrote: >> There is a missing call to tpm_request_locality before the call to >> the tpm_get_timeouts() and tpm_tis_probe_irq_single(). As the current >> approach might work for tpm2, it fails for tpm1.x - in that case >> call to tpm_get_timeouts() or tpm_tis_probe_irq_single() >> without locality fails and in turn causes tpm_tis_core_init() to fail. >> Tested on Samsung Chromebook Pro (Caroline). >>=20 >> Signed-off-by: Lukasz Majczak > > Is it possible that you test against linux-next and see if any > problems still arise? I've applied the locality fixes from James. I tested current linux-next and the warning still appears, unfortunately. I then incrementally applied further patches from James' series [1] and after "[PATCH v2 4/5] tpm_tis: fix IRQ probing" the warning has gone: # dmesg | grep tpm [ 7.220410] tpm_tis STM0125:00: 2.0 TPM (device-id 0x0, rev-id 78) [ 7.322564] Modules linked in: iwlmvm(+) btusb btrtl btbcm btintel mac80= 211 amdgpu(+) iwlwifi drm_ttm_helper tpm_crb sdhci_pci ttm cqhci gpu_sched = sdhci ccp cfg80211 rng_core tpm_tis tpm_tis_core tpm thinkpad_acpi(+) wmi n= vram pinctrl_amd You might notice there is another warning but that is rtc related and I still have to find out if that is something I should report. Dirk [1] https://lore.kernel.org/linux-integrity/20201001180925.13808-1-James.Bo= ttomley@HansenPartnership.com/ >> --- >> Jarkko, James, Guenter >>=20 >> I=E2=80=99m aware about the other thread, but it seems to be dead for a = few months. >> Here is the small patch as fixing this specific issue >> would allow us to unblock the ChromeOs development.=20 >> We want to upstream all of our patches, >> so the ChromeOs will not diverge even more, >> so I'm hoping this could be applied, if you see it neat enough. > > The usual approach is that you construct a series picking the pre-existing > fixes and on top of that create your own, if any required. > >> Best regards, >> Lukasz > > /Jarkko > >>=20 >> v1 -> v2: >> =C2=A0- fixed typos >> =C2=A0- as there is no need to enable clock, switched to >> =C2=A0=C2=A0 use only tpm_request/relinquish_locality calls >> =C2=A0- narrowed down boundaries of tpm_request/relinquish_locality calls >> =C2=A0 >> =C2=A0drivers/char/tpm/tpm-chip.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 = 4 ++-- >> =C2=A0drivers/char/tpm/tpm-interface.c | 11 +++++++++-- >> =C2=A0drivers/char/tpm/tpm.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0 2 ++ >> =C2=A0drivers/char/tpm/tpm_tis_core.c=C2=A0 | 12 ++++++++++-- >> =C2=A04 files changed, 23 insertions(+), 6 deletions(-) >>=20 >> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c >> index ddaeceb7e109..5351963a4b19 100644 >> --- a/drivers/char/tpm/tpm-chip.c >> +++ b/drivers/char/tpm/tpm-chip.c >> @@ -32,7 +32,7 @@ struct class *tpm_class; >> =C2=A0struct class *tpmrm_class; >> =C2=A0dev_t tpm_devt; >> =C2=A0 >> -static int tpm_request_locality(struct tpm_chip *chip) >> +int tpm_request_locality(struct tpm_chip *chip) >> =C2=A0{ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int rc; >> =C2=A0 >> @@ -47,7 +47,7 @@ static int tpm_request_locality(struct tpm_chip *chip) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return 0; >> =C2=A0} >> =C2=A0 >> -static void tpm_relinquish_locality(struct tpm_chip *chip) >> +void tpm_relinquish_locality(struct tpm_chip *chip) >> =C2=A0{ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int rc; >> =C2=A0 >> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-int= erface.c >> index 1621ce818705..69309b2bea6a 100644 >> --- a/drivers/char/tpm/tpm-interface.c >> +++ b/drivers/char/tpm/tpm-interface.c >> @@ -243,8 +243,15 @@ int tpm_get_timeouts(struct tpm_chip *chip) >> =C2=A0 >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (chip->flags & TPM_CH= IP_FLAG_TPM2) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0return tpm2_get_timeouts(chip); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return tpm1_get_timeouts(chip); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0ssize_t ret =3D tpm_request_locality(chip); >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return= ret; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0ret =3D tpm1_get_timeouts(chip); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0tpm_relinquish_locality(chip); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return ret; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} >> =C2=A0} >> =C2=A0EXPORT_SYMBOL_GPL(tpm_get_timeouts); >> =C2=A0 >> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h >> index 947d1db0a5cc..8c13008437dd 100644 >> --- a/drivers/char/tpm/tpm.h >> +++ b/drivers/char/tpm/tpm.h >> @@ -193,6 +193,8 @@ static inline void tpm_msleep(unsigned int delay_mse= c) >> =C2=A0 >> =C2=A0int tpm_chip_start(struct tpm_chip *chip); >> =C2=A0void tpm_chip_stop(struct tpm_chip *chip); >> +int tpm_request_locality(struct tpm_chip *chip); >> +void tpm_relinquish_locality(struct tpm_chip *chip); >> =C2=A0struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip); >> =C2=A0__must_check int tpm_try_get_ops(struct tpm_chip *chip); >> =C2=A0void tpm_put_ops(struct tpm_chip *chip); >> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_= core.c >> index 92c51c6cfd1b..0ae675e8cf2f 100644 >> --- a/drivers/char/tpm/tpm_tis_core.c >> +++ b/drivers/char/tpm/tpm_tis_core.c >> @@ -754,9 +754,17 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *c= hip) >> =C2=A0 >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (chip->flags & TPM_CH= IP_FLAG_TPM2) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &ca= p, desc, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0ssize_t ret =3D tpm_request_locality(chip); >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0if (ret) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return= ret; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0ret =3D tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &c= ap, desc, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0tpm_relinquish_locality(chip); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return ret; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} >> + >> =C2=A0} >> =C2=A0 >> =C2=A0/* Register the IRQ and issue a command that will cause an interru= pt. If an