Skip to content

Commit 44abdb3

Browse files
jejbJarkko Sakkinen
authored andcommitted
tpm: use GFP_KERNEL instead of GFP_HIGHMEM for tpm_buf
The current code uses GFP_HIGHMEM, which is wrong because GFP_HIGHMEM (on 32 bit systems) is memory ordinarily inaccessible to the kernel and should only be used for allocations affecting userspace. In order to make highmem visible to the kernel on 32 bit it has to be kmapped, which consumes valuable entries in the kmap region. Since the tpm_buf is only ever used in the kernel, switch to using a GFP_KERNEL allocation so as not to waste kmap space on 32 bits. Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent f168911 commit 44abdb3

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎drivers/char/tpm/tpm.h‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ enum tpm_buf_flags {
282282
};
283283

284284
struct tpm_buf {
285-
struct page *data_page;
286285
unsigned int flags;
287286
u8 *data;
288287
};
@@ -298,20 +297,18 @@ static inline void tpm_buf_reset(struct tpm_buf *buf, u16 tag, u32 ordinal)
298297

299298
static inline int tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal)
300299
{
301-
buf->data_page = alloc_page(GFP_HIGHUSER);
302-
if (!buf->data_page)
300+
buf->data = (u8 *)__get_free_page(GFP_KERNEL);
301+
if (!buf->data)
303302
return -ENOMEM;
304303

305304
buf->flags = 0;
306-
buf->data = kmap(buf->data_page);
307305
tpm_buf_reset(buf, tag, ordinal);
308306
return 0;
309307
}
310308

311309
static inline void tpm_buf_destroy(struct tpm_buf *buf)
312310
{
313-
kunmap(buf->data_page);
314-
__free_page(buf->data_page);
311+
free_page((unsigned long)buf->data);
315312
}
316313

317314
static inline u32 tpm_buf_length(struct tpm_buf *buf)

0 commit comments

Comments
 (0)