mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org,
	linux-integrity@vger.kernel.org
Cc: ross.philipson@oracle.com, dpsmith@apertussolutions.com,
	jarkko.sakkinen@linux.intel.com, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, hpa@zytor.com,
	luto@amacapital.net, trenchboot-devel@googlegroups.com
Subject: [RFC PATCH 3/4] tpm: Conditionally use static buffer in TPM buffer management
Date: Sat, 31 Oct 2020 12:51:21 -0400	[thread overview]
Message-ID: <20201031165122.21539-4-dpsmith@apertussolutions.com> (raw)
In-Reply-To: <20201031165122.21539-1-dpsmith@apertussolutions.com>

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 <dpsmith@apertussolutions.com>
Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
---
 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


  parent reply	other threads:[~2020-10-31 16:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31 16:51 [RFC PATCH 0/4] Secure Launch early PCR extend support Daniel P. Smith
2020-10-31 16:51 ` [RFC PATCH 1/4] tpm: Move TPM TIS definitions out of TIS core header Daniel P. Smith
2020-10-31 16:51 ` [RFC PATCH 2/4] tpm: Move core definitions and buffer management out of main TPM header Daniel P. Smith
2020-11-02 12:09   ` Jarkko Sakkinen
2020-10-31 16:51 ` Daniel P. Smith [this message]
2020-11-02 12:16   ` [RFC PATCH 3/4] tpm: Conditionally use static buffer in TPM buffer management Jarkko Sakkinen
2020-10-31 16:51 ` [RFC PATCH 4/4] x86: Add early PCR extend support for Secure Launch Daniel P. Smith
2020-11-02 12:19   ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201031165122.21539-4-dpsmith@apertussolutions.com \
    --to=dpsmith@apertussolutions.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=ross.philipson@oracle.com \
    --cc=tglx@linutronix.de \
    --cc=trenchboot-devel@googlegroups.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome