Lines Matching refs:space

31 static void tpm2_flush_sessions(struct tpm_chip *chip, struct tpm_space *space)
35 for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) {
36 if (space->session_tbl[i])
37 tpm2_flush_context(chip, space->session_tbl[i]);
41 int tpm2_init_space(struct tpm_space *space, unsigned int buf_size)
43 space->context_buf = kzalloc(buf_size, GFP_KERNEL);
44 if (!space->context_buf)
47 space->session_buf = kzalloc(buf_size, GFP_KERNEL);
48 if (space->session_buf == NULL) {
49 kfree(space->context_buf);
51 space->context_buf = NULL;
55 space->buf_size = buf_size;
59 void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space)
63 tpm2_flush_sessions(chip, space);
67 kfree(space->context_buf);
68 kfree(space->session_buf);
100 * and loaded outside the space.
103 * flushed outside the space
166 struct tpm_space *space = &chip->work_space;
169 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++)
170 if (space->context_tbl[i] && ~space->context_tbl[i])
171 tpm2_flush_context(chip, space->context_tbl[i]);
173 tpm2_flush_sessions(chip, space);
178 struct tpm_space *space = &chip->work_space;
183 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) {
184 if (!space->context_tbl[i])
188 if (~space->context_tbl[i]) {
193 rc = tpm2_load_context(chip, space->context_buf, &offset,
194 &space->context_tbl[i]);
199 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) {
202 if (!space->session_tbl[i])
205 rc = tpm2_load_context(chip, space->session_buf,
209 space->session_tbl[i] = 0;
214 if (handle != space->session_tbl[i]) {
224 static bool tpm2_map_to_phandle(struct tpm_space *space, void *handle)
231 if (i >= ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i])
234 phandle = space->context_tbl[i];
241 struct tpm_space *space = &chip->work_space;
257 if (!tpm2_map_to_phandle(space, handle))
266 struct tpm_space *space,
300 int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd,
306 if (!space)
309 cc = tpm_find_and_validate_cc(chip, space, cmd, cmdsiz);
313 memcpy(&chip->work_space.context_tbl, &space->context_tbl,
314 sizeof(space->context_tbl));
315 memcpy(&chip->work_space.session_tbl, &space->session_tbl,
316 sizeof(space->session_tbl));
317 memcpy(chip->work_space.context_buf, space->context_buf,
318 space->buf_size);
319 memcpy(chip->work_space.session_buf, space->session_buf,
320 space->buf_size);
340 struct tpm_space *space = &chip->work_space;
343 for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++)
344 if (space->session_tbl[i] == 0)
347 if (i == ARRAY_SIZE(space->session_tbl))
350 space->session_tbl[i] = handle;
354 static u32 tpm2_map_to_vhandle(struct tpm_space *space, u32 phandle, bool alloc)
358 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) {
360 if (!space->context_tbl[i]) {
361 space->context_tbl[i] = phandle;
364 } else if (space->context_tbl[i] == phandle)
368 if (i == ARRAY_SIZE(space->context_tbl))
377 struct tpm_space *space = &chip->work_space;
402 vhandle = tpm2_map_to_vhandle(space, phandle, true);
437 struct tpm_space *space = &chip->work_space;
470 vhandle = tpm2_map_to_vhandle(space, phandle, false);
493 struct tpm_space *space = &chip->work_space;
498 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) {
499 if (!(space->context_tbl[i] && ~space->context_tbl[i]))
502 rc = tpm2_save_context(chip, space->context_tbl[i],
503 space->context_buf, space->buf_size,
506 space->context_tbl[i] = 0;
511 tpm2_flush_context(chip, space->context_tbl[i]);
512 space->context_tbl[i] = ~0;
515 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) {
516 if (!space->session_tbl[i])
519 rc = tpm2_save_context(chip, space->session_tbl[i],
520 space->session_buf, space->buf_size,
524 space->session_tbl[i] = 0;
534 int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
540 if (!space)
563 memcpy(&space->context_tbl, &chip->work_space.context_tbl,
564 sizeof(space->context_tbl));
565 memcpy(&space->session_tbl, &chip->work_space.session_tbl,
566 sizeof(space->session_tbl));
567 memcpy(space->context_buf, chip->work_space.context_buf,
568 space->buf_size);
569 memcpy(space->session_buf, chip->work_space.session_buf,
570 space->buf_size);