Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SessionID allocation issue #1566

Closed
xiangfeima opened this issue Jan 2, 2023 · 0 comments · Fixed by #1567
Closed

SessionID allocation issue #1566

xiangfeima opened this issue Jan 2, 2023 · 0 comments · Fixed by #1567
Assignees
Labels
bug Something isn't working
Milestone

Comments

@xiangfeima
Copy link
Member

xiangfeima commented Jan 2, 2023

This is a follow-up of #1424.
PR #1450, which fixed #1424, did not update the session id allocation process accordingly.
Because from #1450 rsp_session_id occupies the most-significant bytes of a whole session_id,
thus the req_session_id inside libspdm_allocate_req_session_id() should be caululated from 0xFFFF,
and rsp_session_id inside libspdm_allocate_rsp_session_id() should be caululated from 0xFFFF0000.

uint16_t libspdm_allocate_req_session_id(libspdm_context_t *spdm_context)
{
uint16_t req_session_id;
libspdm_session_info_t *session_info;
size_t index;
session_info = spdm_context->session_info;
for (index = 0; index < LIBSPDM_MAX_SESSION_COUNT; index++) {
if ((session_info[index].session_id & 0xFFFF0000) == (INVALID_SESSION_ID & 0xFFFF0000)) {
req_session_id = (uint16_t)(0xFFFF - index);
return req_session_id;
}
}
LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "libspdm_allocate_req_session_id - MAX session_id\n"));
return (INVALID_SESSION_ID & 0xFFFF0000) >> 16;
}

uint16_t libspdm_allocate_rsp_session_id(const libspdm_context_t *spdm_context)
{
uint16_t rsp_session_id;
const libspdm_session_info_t *session_info;
size_t index;
session_info = spdm_context->session_info;
for (index = 0; index < LIBSPDM_MAX_SESSION_COUNT; index++) {
if ((session_info[index].session_id & 0xFFFF) == (INVALID_SESSION_ID & 0xFFFF)) {
rsp_session_id = (uint16_t)(0xFFFF - index);
return rsp_session_id;
}
}
LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "libspdm_allocate_rsp_session_id - MAX session_id\n"));
return (INVALID_SESSION_ID & 0xFFFF);
}

@steven-bellock steven-bellock added the bug Something isn't working label Jan 2, 2023
@steven-bellock steven-bellock added this to the Q4 2022 milestone Jan 2, 2023
@jyao1 jyao1 self-assigned this Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants