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) in tpm2_init_space() argument
43 space->context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL); in tpm2_init_space()
44 if (!space->context_buf) in tpm2_init_space()
47 space->session_buf = kzalloc(PAGE_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()
56 void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space) in tpm2_del_space() argument
60 tpm2_flush_sessions(chip, space); in tpm2_del_space()
64 kfree(space->context_buf); in tpm2_del_space()
65 kfree(space->session_buf); in tpm2_del_space()
163 struct tpm_space *space = &chip->work_space; in tpm2_flush_space() local
166 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) in tpm2_flush_space()
167 if (space->context_tbl[i] && ~space->context_tbl[i]) in tpm2_flush_space()
168 tpm2_flush_context(chip, space->context_tbl[i]); in tpm2_flush_space()
170 tpm2_flush_sessions(chip, space); in tpm2_flush_space()
175 struct tpm_space *space = &chip->work_space; in tpm2_load_space() local
180 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_load_space()
181 if (!space->context_tbl[i]) in tpm2_load_space()
185 if (~space->context_tbl[i]) { in tpm2_load_space()
190 rc = tpm2_load_context(chip, space->context_buf, &offset, in tpm2_load_space()
191 &space->context_tbl[i]); in tpm2_load_space()
196 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_load_space()
199 if (!space->session_tbl[i]) in tpm2_load_space()
202 rc = tpm2_load_context(chip, space->session_buf, in tpm2_load_space()
206 space->session_tbl[i] = 0; in tpm2_load_space()
211 if (handle != space->session_tbl[i]) { in tpm2_load_space()
221 static bool tpm2_map_to_phandle(struct tpm_space *space, void *handle) in tpm2_map_to_phandle() argument
228 if (i >= ARRAY_SIZE(space->context_tbl) || !space->context_tbl[i]) in tpm2_map_to_phandle()
231 phandle = space->context_tbl[i]; in tpm2_map_to_phandle()
238 struct tpm_space *space = &chip->work_space; in tpm2_map_command() local
254 if (!tpm2_map_to_phandle(space, handle)) in tpm2_map_command()
263 struct tpm_space *space, in tpm_find_and_validate_cc() argument
297 int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd, in tpm2_prepare_space() argument
303 if (!space) in tpm2_prepare_space()
306 cc = tpm_find_and_validate_cc(chip, space, cmd, cmdsiz); in tpm2_prepare_space()
310 memcpy(&chip->work_space.context_tbl, &space->context_tbl, in tpm2_prepare_space()
311 sizeof(space->context_tbl)); in tpm2_prepare_space()
312 memcpy(&chip->work_space.session_tbl, &space->session_tbl, in tpm2_prepare_space()
313 sizeof(space->session_tbl)); in tpm2_prepare_space()
314 memcpy(chip->work_space.context_buf, space->context_buf, PAGE_SIZE); in tpm2_prepare_space()
315 memcpy(chip->work_space.session_buf, space->session_buf, PAGE_SIZE); in tpm2_prepare_space()
335 struct tpm_space *space = &chip->work_space; in tpm2_add_session() local
338 for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) in tpm2_add_session()
339 if (space->session_tbl[i] == 0) in tpm2_add_session()
342 if (i == ARRAY_SIZE(space->session_tbl)) in tpm2_add_session()
345 space->session_tbl[i] = handle; in tpm2_add_session()
349 static u32 tpm2_map_to_vhandle(struct tpm_space *space, u32 phandle, bool alloc) in tpm2_map_to_vhandle() argument
353 for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_map_to_vhandle()
355 if (!space->context_tbl[i]) { in tpm2_map_to_vhandle()
356 space->context_tbl[i] = phandle; in tpm2_map_to_vhandle()
359 } else if (space->context_tbl[i] == phandle) in tpm2_map_to_vhandle()
363 if (i == ARRAY_SIZE(space->context_tbl)) in tpm2_map_to_vhandle()
372 struct tpm_space *space = &chip->work_space; in tpm2_map_response_header() local
397 vhandle = tpm2_map_to_vhandle(space, phandle, true); in tpm2_map_response_header()
432 struct tpm_space *space = &chip->work_space; in tpm2_map_response_body() local
462 vhandle = tpm2_map_to_vhandle(space, phandle, false); in tpm2_map_response_body()
485 struct tpm_space *space = &chip->work_space; in tpm2_save_space() local
490 for (i = 0, offset = 0; i < ARRAY_SIZE(space->context_tbl); i++) { in tpm2_save_space()
491 if (!(space->context_tbl[i] && ~space->context_tbl[i])) in tpm2_save_space()
494 rc = tpm2_save_context(chip, space->context_tbl[i], in tpm2_save_space()
495 space->context_buf, PAGE_SIZE, in tpm2_save_space()
498 space->context_tbl[i] = 0; in tpm2_save_space()
503 tpm2_flush_context(chip, space->context_tbl[i]); in tpm2_save_space()
504 space->context_tbl[i] = ~0; in tpm2_save_space()
507 for (i = 0, offset = 0; i < ARRAY_SIZE(space->session_tbl); i++) { in tpm2_save_space()
508 if (!space->session_tbl[i]) in tpm2_save_space()
511 rc = tpm2_save_context(chip, space->session_tbl[i], in tpm2_save_space()
512 space->session_buf, PAGE_SIZE, in tpm2_save_space()
517 space->session_tbl[i] = 0; in tpm2_save_space()
527 int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, in tpm2_commit_space() argument
533 if (!space) in tpm2_commit_space()
556 memcpy(&space->context_tbl, &chip->work_space.context_tbl, in tpm2_commit_space()
557 sizeof(space->context_tbl)); in tpm2_commit_space()
558 memcpy(&space->session_tbl, &chip->work_space.session_tbl, in tpm2_commit_space()
559 sizeof(space->session_tbl)); in tpm2_commit_space()
560 memcpy(space->context_buf, chip->work_space.context_buf, PAGE_SIZE); in tpm2_commit_space()
561 memcpy(space->session_buf, chip->work_space.session_buf, PAGE_SIZE); in tpm2_commit_space()