Lines Matching full:space
35 static void tpm2_flush_sessions(struct tpm_chip *chip, struct tpm_space *space) in tpm2_flush_sessions() argument
39 for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_flush_sessions()
40 if (space->session_tbl[i]) in tpm2_flush_sessions()
41 tpm2_flush_context_cmd(chip, space->session_tbl[i], in tpm2_flush_sessions()
46 int tpm2_init_space(struct tpm_space *space, unsigned int buf_size) in tpm2_init_space() argument
48 space->context_buf = kzalloc(buf_size, GFP_KERNEL); in tpm2_init_space()
49 if (!space->context_buf) in tpm2_init_space()
52 space->session_buf = kzalloc(buf_size, GFP_KERNEL); in tpm2_init_space()
53 if (space->session_buf == NULL) { in tpm2_init_space()
54 kfree(space->context_buf); in tpm2_init_space()
56 space->context_buf = NULL; in tpm2_init_space()
60 space->buf_size = buf_size; in tpm2_init_space()
64 void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space) in tpm2_del_space() argument
67 tpm2_flush_sessions(chip, space); in tpm2_del_space()
69 kfree(space->context_buf); in tpm2_del_space()
70 kfree(space->session_buf); in tpm2_del_space()
103 * and loaded outside the space. in tpm2_load_context()
106 * flushed outside the space in tpm2_load_context()
170 struct tpm_space *space = &chip->work_space; in tpm2_flush_space() local
173 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) in tpm2_flush_space()
174 if (space->context_tbl[i] && ~space->context_tbl[i]) in tpm2_flush_space()
175 tpm2_flush_context_cmd(chip, space->context_tbl[i], in tpm2_flush_space()
178 tpm2_flush_sessions(chip, space); in tpm2_flush_space()
183 struct tpm_space *space = &chip->work_space; in tpm2_load_space() local
188 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_load_space()
189 if (!space->context_tbl[i]) in tpm2_load_space()
193 if (~space->context_tbl[i]) { in tpm2_load_space()
198 rc = tpm2_load_context(chip, space->context_buf, &offset, in tpm2_load_space()
199 &space->context_tbl[i]); in tpm2_load_space()
204 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_load_space()
207 if (!space->session_tbl[i]) in tpm2_load_space()
210 rc = tpm2_load_context(chip, space->session_buf, in tpm2_load_space()
214 space->session_tbl[i] = 0; in tpm2_load_space()
219 if (handle != space->session_tbl[i]) { in tpm2_load_space()
229 static bool tpm2_map_to_phandle(struct tpm_space *space, void *handle) in tpm2_map_to_phandle() argument
236 if (i >= ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i]) in tpm2_map_to_phandle()
239 phandle = space->context_tbl[i]; in tpm2_map_to_phandle()
246 struct tpm_space *space = &chip->work_space; in tpm2_map_command() local
262 if (!tpm2_map_to_phandle(space, handle)) in tpm2_map_command()
270 int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u32 cc, in tpm2_prepare_space() argument
275 if (!space) in tpm2_prepare_space()
278 memcpy(&chip->work_space.context_tbl, &space->context_tbl, in tpm2_prepare_space()
279 sizeof(space->context_tbl)); in tpm2_prepare_space()
280 memcpy(&chip->work_space.session_tbl, &space->session_tbl, in tpm2_prepare_space()
281 sizeof(space->session_tbl)); in tpm2_prepare_space()
282 memcpy(chip->work_space.context_buf, space->context_buf, in tpm2_prepare_space()
283 space->buf_size); in tpm2_prepare_space()
284 memcpy(chip->work_space.session_buf, space->session_buf, in tpm2_prepare_space()
285 space->buf_size); in tpm2_prepare_space()
304 struct tpm_space *space = &chip->work_space; in tpm2_add_session() local
307 for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) in tpm2_add_session()
308 if (space->session_tbl[i] == 0) in tpm2_add_session()
311 if (i == ARRAY_SIZE(space->session_tbl)) in tpm2_add_session()
314 space->session_tbl[i] = handle; in tpm2_add_session()
318 static u32 tpm2_map_to_vhandle(struct tpm_space *space, u32 phandle, bool alloc) in tpm2_map_to_vhandle() argument
322 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_map_to_vhandle()
324 if (!space->context_tbl[i]) { in tpm2_map_to_vhandle()
325 space->context_tbl[i] = phandle; in tpm2_map_to_vhandle()
328 } else if (space->context_tbl[i] == phandle) in tpm2_map_to_vhandle()
332 if (i == ARRAY_SIZE(space->context_tbl)) in tpm2_map_to_vhandle()
341 struct tpm_space *space = &chip->work_space; in tpm2_map_response_header() local
366 vhandle = tpm2_map_to_vhandle(space, phandle, true); in tpm2_map_response_header()
401 struct tpm_space *space = &chip->work_space; in tpm2_map_response_body() local
431 vhandle = tpm2_map_to_vhandle(space, phandle, false); in tpm2_map_response_body()
454 struct tpm_space *space = &chip->work_space; in tpm2_save_space() local
459 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_save_space()
460 if (!(space->context_tbl[i] && ~space->context_tbl[i])) in tpm2_save_space()
463 rc = tpm2_save_context(chip, space->context_tbl[i], in tpm2_save_space()
464 space->context_buf, space->buf_size, in tpm2_save_space()
467 space->context_tbl[i] = 0; in tpm2_save_space()
472 tpm2_flush_context_cmd(chip, space->context_tbl[i], in tpm2_save_space()
474 space->context_tbl[i] = ~0; in tpm2_save_space()
477 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_save_space()
478 if (!space->session_tbl[i]) in tpm2_save_space()
481 rc = tpm2_save_context(chip, space->session_tbl[i], in tpm2_save_space()
482 space->session_buf, space->buf_size, in tpm2_save_space()
486 space->session_tbl[i] = 0; in tpm2_save_space()
496 int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, in tpm2_commit_space() argument
502 if (!space) in tpm2_commit_space()
525 memcpy(&space->context_tbl, &chip->work_space.context_tbl, in tpm2_commit_space()
526 sizeof(space->context_tbl)); in tpm2_commit_space()
527 memcpy(&space->session_tbl, &chip->work_space.session_tbl, in tpm2_commit_space()
528 sizeof(space->session_tbl)); in tpm2_commit_space()
529 memcpy(space->context_buf, chip->work_space.context_buf, in tpm2_commit_space()
530 space->buf_size); in tpm2_commit_space()
531 memcpy(space->session_buf, chip->work_space.session_buf, in tpm2_commit_space()
532 space->buf_size); in tpm2_commit_space()