Lines Matching refs: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()
166 struct tpm_space *space = &chip->work_space; in tpm2_flush_space() local
169 if (!space) in tpm2_flush_space()
172 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) in tpm2_flush_space()
173 if (space->context_tbl[i] && ~space->context_tbl[i]) in tpm2_flush_space()
174 tpm2_flush_context(chip, space->context_tbl[i]); in tpm2_flush_space()
176 tpm2_flush_sessions(chip, space); in tpm2_flush_space()
181 struct tpm_space *space = &chip->work_space; in tpm2_load_space() local
186 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_load_space()
187 if (!space->context_tbl[i]) in tpm2_load_space()
191 if (~space->context_tbl[i]) { in tpm2_load_space()
196 rc = tpm2_load_context(chip, space->context_buf, &offset, in tpm2_load_space()
197 &space->context_tbl[i]); in tpm2_load_space()
202 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_load_space()
205 if (!space->session_tbl[i]) in tpm2_load_space()
208 rc = tpm2_load_context(chip, space->session_buf, in tpm2_load_space()
212 space->session_tbl[i] = 0; in tpm2_load_space()
217 if (handle != space->session_tbl[i]) { in tpm2_load_space()
227 static bool tpm2_map_to_phandle(struct tpm_space *space, void *handle) in tpm2_map_to_phandle() argument
234 if (i >= ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i]) in tpm2_map_to_phandle()
237 phandle = space->context_tbl[i]; in tpm2_map_to_phandle()
244 struct tpm_space *space = &chip->work_space; in tpm2_map_command() local
260 if (!tpm2_map_to_phandle(space, handle)) in tpm2_map_command()
269 struct tpm_space *space, in tpm_find_and_validate_cc() argument
303 int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd, in tpm2_prepare_space() argument
309 if (!space) in tpm2_prepare_space()
312 cc = tpm_find_and_validate_cc(chip, space, cmd, cmdsiz); in tpm2_prepare_space()
316 memcpy(&chip->work_space.context_tbl, &space->context_tbl, in tpm2_prepare_space()
317 sizeof(space->context_tbl)); in tpm2_prepare_space()
318 memcpy(&chip->work_space.session_tbl, &space->session_tbl, in tpm2_prepare_space()
319 sizeof(space->session_tbl)); in tpm2_prepare_space()
320 memcpy(chip->work_space.context_buf, space->context_buf, in tpm2_prepare_space()
321 space->buf_size); in tpm2_prepare_space()
322 memcpy(chip->work_space.session_buf, space->session_buf, in tpm2_prepare_space()
323 space->buf_size); in tpm2_prepare_space()
343 struct tpm_space *space = &chip->work_space; in tpm2_add_session() local
346 for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) in tpm2_add_session()
347 if (space->session_tbl[i] == 0) in tpm2_add_session()
350 if (i == ARRAY_SIZE(space->session_tbl)) in tpm2_add_session()
353 space->session_tbl[i] = handle; in tpm2_add_session()
357 static u32 tpm2_map_to_vhandle(struct tpm_space *space, u32 phandle, bool alloc) in tpm2_map_to_vhandle() argument
361 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_map_to_vhandle()
363 if (!space->context_tbl[i]) { in tpm2_map_to_vhandle()
364 space->context_tbl[i] = phandle; in tpm2_map_to_vhandle()
367 } else if (space->context_tbl[i] == phandle) in tpm2_map_to_vhandle()
371 if (i == ARRAY_SIZE(space->context_tbl)) in tpm2_map_to_vhandle()
380 struct tpm_space *space = &chip->work_space; in tpm2_map_response_header() local
405 vhandle = tpm2_map_to_vhandle(space, phandle, true); in tpm2_map_response_header()
440 struct tpm_space *space = &chip->work_space; in tpm2_map_response_body() local
473 vhandle = tpm2_map_to_vhandle(space, phandle, false); in tpm2_map_response_body()
496 struct tpm_space *space = &chip->work_space; in tpm2_save_space() local
501 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_save_space()
502 if (!(space->context_tbl[i] && ~space->context_tbl[i])) in tpm2_save_space()
505 rc = tpm2_save_context(chip, space->context_tbl[i], in tpm2_save_space()
506 space->context_buf, space->buf_size, in tpm2_save_space()
509 space->context_tbl[i] = 0; in tpm2_save_space()
514 tpm2_flush_context(chip, space->context_tbl[i]); in tpm2_save_space()
515 space->context_tbl[i] = ~0; in tpm2_save_space()
518 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_save_space()
519 if (!space->session_tbl[i]) in tpm2_save_space()
522 rc = tpm2_save_context(chip, space->session_tbl[i], in tpm2_save_space()
523 space->session_buf, space->buf_size, in tpm2_save_space()
527 space->session_tbl[i] = 0; in tpm2_save_space()
537 int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, in tpm2_commit_space() argument
543 if (!space) in tpm2_commit_space()
566 memcpy(&space->context_tbl, &chip->work_space.context_tbl, in tpm2_commit_space()
567 sizeof(space->context_tbl)); in tpm2_commit_space()
568 memcpy(&space->session_tbl, &chip->work_space.session_tbl, in tpm2_commit_space()
569 sizeof(space->session_tbl)); in tpm2_commit_space()
570 memcpy(space->context_buf, chip->work_space.context_buf, in tpm2_commit_space()
571 space->buf_size); in tpm2_commit_space()
572 memcpy(space->session_buf, chip->work_space.session_buf, in tpm2_commit_space()
573 space->buf_size); in tpm2_commit_space()