Lines Matching full:space

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