Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3253011pxx; Mon, 2 Nov 2020 04:18:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzru/0Qd5wELA9JzB6CR5gFhtewBjvFpaSv8qlQ8pLxVBaMsUKoAsnUnFrny+Pl1S+fzWIX X-Received: by 2002:a17:907:42a1:: with SMTP id nf1mr15606736ejb.135.1604319537512; Mon, 02 Nov 2020 04:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604319537; cv=none; d=google.com; s=arc-20160816; b=smzAotENsFFv7i3UbeDbTMNmofufU1jLZ19H/DX+eXIryCK7Dpc0MUg+uoFeTlu5xL xyUrnr/sg2Bq7VChE/KuyMfe8Nae7CVv5F0l3cmmOGt5kJFqQJ00/x9fhf3PIORObojt JEuuPzqt17sLf4o1GH7ecnWPKayP0xkvG3gUbzdRRpnY5W3uQ+zHuz+7f5UYHppgJ5Gc 9MuQI/Sb+VUNyPG7MqKFyY8aY8lcD5KI7+60K41ej8+h20RjAuh7TBsNSnuyTLpx6LM/ 4qqJvArdqN20d3Q5zhnB53/u6PpS5xoM1nl7r2BjFbTFFOU/SfJjsXWZGxmgJ7mhIc+l WdCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=/5sbCxtGdSxN3uvade2e3FpFyoyoVsRksHsTlt/epM4=; b=Jb3TGkQLmq+2Rja9lyyNdo6F4fkW5k1VLzMss95P7BITmMLMcGXjmAKf9VBnXXqmMP uQpBD+yXwjvpVAvXsOKvjKoMBPq5Gj+rBBaErGJEi/PB4g0EJY+GRXENjNk+PcbZt+Gy dhL+K6m8dp2b939vH1bxTdniAXYt9+FgsWmopeinOtyU0ak9mqgZx1eV217XWnX+Xb8I Fu2XKlbelbIbx2cDzOZ8e8uB0JaEVH6kQF27IP78Ferc9EU1oM3StvYXj81MzFLbVdD6 BYxp/tEw8k7Bweu1nYmwSHqAMKBz0fTkLgUwDHoaAZiPNKHofnRp2Pa2J5dPoQMq8EiQ kGmw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx11si11685991edb.409.2020.11.02.04.18.34; Mon, 02 Nov 2020 04:18:57 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728627AbgKBMQt (ORCPT + 99 others); Mon, 2 Nov 2020 07:16:49 -0500 Received: from mga03.intel.com ([134.134.136.65]:28865 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728359AbgKBMQt (ORCPT ); Mon, 2 Nov 2020 07:16:49 -0500 IronPort-SDR: o0aHOT3rPfclYcOXhsalnykM8+A1FQUIMiiE4ukVkYQXjUZiQ0iArDK3cGnC/FiM5MPHXavl/0 bPx3Vh0JH8kQ== X-IronPort-AV: E=McAfee;i="6000,8403,9792"; a="168972646" X-IronPort-AV: E=Sophos;i="5.77,444,1596524400"; d="scan'208";a="168972646" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 04:16:48 -0800 IronPort-SDR: bM3ptaXzkv/iFqswyOPD70Rz4tqdTi+PMKIg5vi40sI67LQ4/qPXSa60A2xRHnj27/iaPcCfRE o0NPBu98S4NQ== X-IronPort-AV: E=Sophos;i="5.77,444,1596524400"; d="scan'208";a="305420857" Received: from jpanina-mobl2.ger.corp.intel.com (HELO linux.intel.com) ([10.252.49.91]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 04:16:42 -0800 Date: Mon, 2 Nov 2020 14:16:37 +0200 From: Jarkko Sakkinen To: "Daniel P. Smith" Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-integrity@vger.kernel.org, ross.philipson@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, luto@amacapital.net, trenchboot-devel@googlegroups.com Subject: Re: [RFC PATCH 3/4] tpm: Conditionally use static buffer in TPM buffer management Message-ID: <20201102121637.GB5242@linux.intel.com> References: <20201031165122.21539-1-dpsmith@apertussolutions.com> <20201031165122.21539-4-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201031165122.21539-4-dpsmith@apertussolutions.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 31, 2020 at 12:51:21PM -0400, Daniel P. Smith wrote: > Memory management calls cannot be made in the compressed kernel > environment to dynamically allocate TPM buffer space. For the Secure > Launch early PCR extend code, use a static buffer instead. > > Signed-off-by: Daniel P. Smith > Signed-off-by: Ross Philipson > --- This patch is not necessary. Just assign tb->data to the static buffer where you use the static buffer and use tpm_buf_reset(). tpm_buf_init() and tpm_buf_destroy() are optional. /Jarkko > include/linux/tpm_buffer.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/include/linux/tpm_buffer.h b/include/linux/tpm_buffer.h > index 8144a52fbc0a..c9482edf6618 100644 > --- a/include/linux/tpm_buffer.h > +++ b/include/linux/tpm_buffer.h > @@ -18,6 +18,10 @@ > #ifndef __LINUX_TPM_BUFFER_H__ > #define __LINUX_TPM_BUFFER_H__ > > +#ifdef COMPRESSED_KERNEL > +static u8 _tpm_buffer[PAGE_SIZE] = {0}; > +#endif > + > struct tpm_header { > __be16 tag; > __be32 length; > @@ -52,7 +56,11 @@ static inline void tpm_buf_reset(struct tpm_buf *buf, u16 tag, u32 ordinal) > > static inline int tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal) > { > +#ifdef COMPRESSED_KERNEL > + buf->data = _tpm_buffer; > +#else > buf->data = (u8 *)__get_free_page(GFP_KERNEL); > +#endif > if (!buf->data) > return -ENOMEM; > > @@ -63,7 +71,9 @@ static inline int tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal) > > static inline void tpm_buf_destroy(struct tpm_buf *buf) > { > +#ifndef COMPRESSED_KERNEL > free_page((unsigned long)buf->data); > +#endif > } > > static inline u32 tpm_buf_length(struct tpm_buf *buf) > @@ -92,7 +102,9 @@ static inline void tpm_buf_append(struct tpm_buf *buf, > return; > > if ((len + new_len) > PAGE_SIZE) { > +#ifndef COMPRESSED_KERNEL > WARN(1, "tpm_buf: overflow\n"); > +#endif > buf->flags |= TPM_BUF_OVERFLOW; > return; > } > -- > 2.11.0 > /Jarkko