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()
169 struct tpm_space *space = &chip->work_space; in tpm2_flush_space() local
172 if (!space) in tpm2_flush_space()
175 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) in tpm2_flush_space()
176 if (space->context_tbl[i] && ~space->context_tbl[i]) in tpm2_flush_space()
177 tpm2_flush_context(chip, space->context_tbl[i]); in tpm2_flush_space()
179 tpm2_flush_sessions(chip, space); in tpm2_flush_space()
184 struct tpm_space *space = &chip->work_space; in tpm2_load_space() local
189 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_load_space()
190 if (!space->context_tbl[i]) in tpm2_load_space()
194 if (~space->context_tbl[i]) { in tpm2_load_space()
199 rc = tpm2_load_context(chip, space->context_buf, &offset, in tpm2_load_space()
200 &space->context_tbl[i]); in tpm2_load_space()
205 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_load_space()
208 if (!space->session_tbl[i]) in tpm2_load_space()
211 rc = tpm2_load_context(chip, space->session_buf, in tpm2_load_space()
215 space->session_tbl[i] = 0; in tpm2_load_space()
220 if (handle != space->session_tbl[i]) { in tpm2_load_space()
230 static bool tpm2_map_to_phandle(struct tpm_space *space, void *handle) in tpm2_map_to_phandle() argument
237 if (i >= ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i]) in tpm2_map_to_phandle()
240 phandle = space->context_tbl[i]; in tpm2_map_to_phandle()
247 struct tpm_space *space = &chip->work_space; in tpm2_map_command() local
263 if (!tpm2_map_to_phandle(space, handle)) in tpm2_map_command()
272 struct tpm_space *space, in tpm_find_and_validate_cc() argument
306 int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd, in tpm2_prepare_space() argument
312 if (!space) in tpm2_prepare_space()
315 cc = tpm_find_and_validate_cc(chip, space, cmd, cmdsiz); in tpm2_prepare_space()
319 memcpy(&chip->work_space.context_tbl, &space->context_tbl, in tpm2_prepare_space()
320 sizeof(space->context_tbl)); in tpm2_prepare_space()
321 memcpy(&chip->work_space.session_tbl, &space->session_tbl, in tpm2_prepare_space()
322 sizeof(space->session_tbl)); in tpm2_prepare_space()
323 memcpy(chip->work_space.context_buf, space->context_buf, in tpm2_prepare_space()
324 space->buf_size); in tpm2_prepare_space()
325 memcpy(chip->work_space.session_buf, space->session_buf, in tpm2_prepare_space()
326 space->buf_size); in tpm2_prepare_space()
346 struct tpm_space *space = &chip->work_space; in tpm2_add_session() local
349 for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) in tpm2_add_session()
350 if (space->session_tbl[i] == 0) in tpm2_add_session()
353 if (i == ARRAY_SIZE(space->session_tbl)) in tpm2_add_session()
356 space->session_tbl[i] = handle; in tpm2_add_session()
360 static u32 tpm2_map_to_vhandle(struct tpm_space *space, u32 phandle, bool alloc) in tpm2_map_to_vhandle() argument
364 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_map_to_vhandle()
366 if (!space->context_tbl[i]) { in tpm2_map_to_vhandle()
367 space->context_tbl[i] = phandle; in tpm2_map_to_vhandle()
370 } else if (space->context_tbl[i] == phandle) in tpm2_map_to_vhandle()
374 if (i == ARRAY_SIZE(space->context_tbl)) in tpm2_map_to_vhandle()
383 struct tpm_space *space = &chip->work_space; in tpm2_map_response_header() local
408 vhandle = tpm2_map_to_vhandle(space, phandle, true); in tpm2_map_response_header()
443 struct tpm_space *space = &chip->work_space; in tpm2_map_response_body() local
476 vhandle = tpm2_map_to_vhandle(space, phandle, false); in tpm2_map_response_body()
499 struct tpm_space *space = &chip->work_space; in tpm2_save_space() local
504 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_save_space()
505 if (!(space->context_tbl[i] && ~space->context_tbl[i])) in tpm2_save_space()
508 rc = tpm2_save_context(chip, space->context_tbl[i], in tpm2_save_space()
509 space->context_buf, space->buf_size, in tpm2_save_space()
512 space->context_tbl[i] = 0; in tpm2_save_space()
517 tpm2_flush_context(chip, space->context_tbl[i]); in tpm2_save_space()
518 space->context_tbl[i] = ~0; in tpm2_save_space()
521 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_save_space()
522 if (!space->session_tbl[i]) in tpm2_save_space()
525 rc = tpm2_save_context(chip, space->session_tbl[i], in tpm2_save_space()
526 space->session_buf, space->buf_size, in tpm2_save_space()
530 space->session_tbl[i] = 0; in tpm2_save_space()
540 int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, in tpm2_commit_space() argument
546 if (!space) in tpm2_commit_space()
569 memcpy(&space->context_tbl, &chip->work_space.context_tbl, in tpm2_commit_space()
570 sizeof(space->context_tbl)); in tpm2_commit_space()
571 memcpy(&space->session_tbl, &chip->work_space.session_tbl, in tpm2_commit_space()
572 sizeof(space->session_tbl)); in tpm2_commit_space()
573 memcpy(space->context_buf, chip->work_space.context_buf, in tpm2_commit_space()
574 space->buf_size); in tpm2_commit_space()
575 memcpy(space->session_buf, chip->work_space.session_buf, in tpm2_commit_space()
576 space->buf_size); in tpm2_commit_space()