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

enlarge response buffer for error message #384

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/library/cxl_tsp_common_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#define LIBCXLTSP_CONFIGURATION_REPORT_PORTION_LEN 0x40

#define LIBCXLTSP_ERROR_MESSAGE_MAX_SIZE (sizeof(cxl_tsp_error_rsp_t))

typedef struct {
uint16_t memory_encryption_features_supported;
uint32_t memory_encryption_algorithms_supported;
Expand Down
4 changes: 3 additions & 1 deletion include/library/pci_tdisp_common_lib.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright Notice:
* Copyright 2021-2022 DMTF. All rights reserved.
* Copyright 2021-2024 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

Expand All @@ -14,4 +14,6 @@

#define LIBTDISP_INTERFACE_REPORT_PORTION_LEN 0x40

#define LIBTDISP_ERROR_MESSAGE_MAX_SIZE (sizeof(pci_tdisp_error_response_t))

#endif
16 changes: 9 additions & 7 deletions library/cxl_tsp_requester_lib/cxl_tsp_req_get_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,38 @@ libspdm_return_t cxl_tsp_get_version(
libspdm_return_t status;
cxl_tsp_get_target_tsp_version_req_t request;
size_t request_size;
cxl_tsp_get_target_tsp_version_rsp_mine_t response;
uint8_t res_buf[LIBCXLTSP_ERROR_MESSAGE_MAX_SIZE];
cxl_tsp_get_target_tsp_version_rsp_mine_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
request.header.tsp_version = CXL_TSP_MESSAGE_VERSION_10;
request.header.op_code = CXL_TSP_OPCODE_GET_TARGET_TSP_VERSION;

request_size = sizeof(request);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = cxl_tsp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

if (response_size != sizeof(cxl_tsp_get_target_tsp_version_rsp_mine_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.tsp_version != request.header.tsp_version) {
if (response->header.tsp_version != request.header.tsp_version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.op_code != CXL_TSP_OPCODE_GET_TARGET_TSP_VERSION_RSP) {
if (response->header.op_code != CXL_TSP_OPCODE_GET_TARGET_TSP_VERSION_RSP) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

if (response.version_number_entry_count != 1) {
if (response->version_number_entry_count != 1) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.version_number_entry[0] != CXL_TSP_MESSAGE_VERSION_10) {
if (response->version_number_entry[0] != CXL_TSP_MESSAGE_VERSION_10) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

Expand Down
12 changes: 7 additions & 5 deletions library/cxl_tsp_requester_lib/cxl_tsp_req_lock_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,31 @@ libspdm_return_t cxl_tsp_lock_configuration(
libspdm_return_t status;
cxl_tsp_lock_target_configuration_req_t request;
size_t request_size;
cxl_tsp_lock_target_configuration_rsp_t response;
uint8_t res_buf[LIBCXLTSP_ERROR_MESSAGE_MAX_SIZE];
cxl_tsp_lock_target_configuration_rsp_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
request.header.tsp_version = CXL_TSP_MESSAGE_VERSION_10;
request.header.op_code = CXL_TSP_OPCODE_LOCK_TARGET_CONFIGURATION;

request_size = sizeof(request);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = cxl_tsp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

if (response_size != sizeof(cxl_tsp_lock_target_configuration_rsp_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.tsp_version != request.header.tsp_version) {
if (response->header.tsp_version != request.header.tsp_version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.op_code != CXL_TSP_OPCODE_LOCK_TARGET_CONFIGURATION_RSP) {
if (response->header.op_code != CXL_TSP_OPCODE_LOCK_TARGET_CONFIGURATION_RSP) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

Expand Down
12 changes: 7 additions & 5 deletions library/cxl_tsp_requester_lib/cxl_tsp_req_set_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ libspdm_return_t cxl_tsp_set_configuration(
libspdm_return_t status;
cxl_tsp_set_target_configuration_req_t request;
size_t request_size;
cxl_tsp_set_target_configuration_rsp_t response;
uint8_t res_buf[LIBCXLTSP_ERROR_MESSAGE_MAX_SIZE];
cxl_tsp_set_target_configuration_rsp_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
Expand Down Expand Up @@ -59,21 +60,22 @@ libspdm_return_t cxl_tsp_set_configuration(
sizeof(device_2nd_session_info->secondary_session_psk_key_material));

request_size = sizeof(request);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = cxl_tsp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

if (response_size != sizeof(cxl_tsp_set_target_configuration_rsp_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.tsp_version != request.header.tsp_version) {
if (response->header.tsp_version != request.header.tsp_version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.op_code != CXL_TSP_OPCODE_SET_TARGET_CONFIGURATION_RSP) {
if (response->header.op_code != CXL_TSP_OPCODE_SET_TARGET_CONFIGURATION_RSP) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

Expand Down
12 changes: 7 additions & 5 deletions library/cxl_tsp_requester_lib/cxl_tsp_req_set_te_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ libspdm_return_t cxl_tsp_set_te_state(
libspdm_return_t status;
cxl_tsp_set_target_te_state_req_mine_t request;
size_t request_size;
cxl_tsp_set_target_te_state_rsp_t response;
uint8_t res_buf[LIBCXLTSP_ERROR_MESSAGE_MAX_SIZE];
cxl_tsp_set_target_te_state_rsp_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
Expand All @@ -60,21 +61,22 @@ libspdm_return_t cxl_tsp_set_te_state(

request_size = sizeof(cxl_tsp_set_target_te_state_req_t) +
number_of_memory_ranges * sizeof(cxl_tsp_memory_range_t);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = cxl_tsp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

if (response_size != sizeof(cxl_tsp_set_target_te_state_rsp_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.tsp_version != request.header.tsp_version) {
if (response->header.tsp_version != request.header.tsp_version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.op_code != CXL_TSP_OPCODE_SET_TARGET_TE_STATE_RSP) {
if (response->header.op_code != CXL_TSP_OPCODE_SET_TARGET_TE_STATE_RSP) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright Notice:
* Copyright 2021-2022 DMTF. All rights reserved.
* Copyright 2021-2024 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

Expand Down Expand Up @@ -29,7 +29,8 @@ libspdm_return_t pci_tdisp_get_interface_state(const void *pci_doe_context,
libspdm_return_t status;
pci_tdisp_get_device_interface_state_request_t request;
size_t request_size;
pci_tdisp_device_interface_state_response_t response;
uint8_t res_buf[LIBTDISP_ERROR_MESSAGE_MAX_SIZE];
pci_tdisp_device_interface_state_response_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
Expand All @@ -38,28 +39,29 @@ libspdm_return_t pci_tdisp_get_interface_state(const void *pci_doe_context,
request.header.interface_id.function_id = interface_id->function_id;

request_size = sizeof(request);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = pci_tdisp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

if (response_size != sizeof(pci_tdisp_device_interface_state_response_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.version != request.header.version) {
if (response->header.version != request.header.version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.message_type != PCI_TDISP_DEVICE_INTERFACE_STATE) {
if (response->header.message_type != PCI_TDISP_DEVICE_INTERFACE_STATE) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.interface_id.function_id != request.header.interface_id.function_id) {
if (response->header.interface_id.function_id != request.header.interface_id.function_id) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

*tdi_state = response.tdi_state;
*tdi_state = response->tdi_state;

return LIBSPDM_STATUS_SUCCESS;
}
20 changes: 11 additions & 9 deletions library/pci_tdisp_requester_lib/pci_tdisp_req_get_version.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright Notice:
* Copyright 2021-2022 DMTF. All rights reserved.
* Copyright 2021-2024 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

Expand Down Expand Up @@ -36,7 +36,8 @@ libspdm_return_t pci_tdisp_get_version(const void *pci_doe_context,
libspdm_return_t status;
pci_tdisp_get_version_request_t request;
size_t request_size;
pci_tdisp_version_response_mine_t response;
uint8_t res_buf[LIBTDISP_ERROR_MESSAGE_MAX_SIZE];
pci_tdisp_version_response_mine_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
Expand All @@ -45,31 +46,32 @@ libspdm_return_t pci_tdisp_get_version(const void *pci_doe_context,
request.header.interface_id.function_id = interface_id->function_id;

request_size = sizeof(request);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = pci_tdisp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

if (response_size != sizeof(pci_tdisp_version_response_mine_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.version != request.header.version) {
if (response->header.version != request.header.version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.message_type != PCI_TDISP_VERSION) {
if (response->header.message_type != PCI_TDISP_VERSION) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.interface_id.function_id != request.header.interface_id.function_id) {
if (response->header.interface_id.function_id != request.header.interface_id.function_id) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

if (response.version_num_count != 1) {
if (response->version_num_count != 1) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.version_num_entry[0] != PCI_TDISP_MESSAGE_VERSION_10) {
if (response->version_num_entry[0] != PCI_TDISP_MESSAGE_VERSION_10) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright Notice:
* Copyright 2021-2022 DMTF. All rights reserved.
* Copyright 2021-2024 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

Expand Down Expand Up @@ -29,7 +29,8 @@ libspdm_return_t pci_tdisp_start_interface(const void *pci_doe_context,
libspdm_return_t status;
pci_tdisp_start_interface_request_t request;
size_t request_size;
pci_tdisp_start_interface_response_t response;
uint8_t res_buf[LIBTDISP_ERROR_MESSAGE_MAX_SIZE];
pci_tdisp_start_interface_response_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
Expand All @@ -40,10 +41,11 @@ libspdm_return_t pci_tdisp_start_interface(const void *pci_doe_context,
start_interface_nonce, PCI_TDISP_START_INTERFACE_NONCE_SIZE);

request_size = sizeof(request);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = pci_tdisp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
libspdm_zero_mem (&request.start_interface_nonce, sizeof(request.start_interface_nonce));
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
Expand All @@ -52,13 +54,13 @@ libspdm_return_t pci_tdisp_start_interface(const void *pci_doe_context,
if (response_size != sizeof(pci_tdisp_start_interface_response_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.version != request.header.version) {
if (response->header.version != request.header.version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.message_type != PCI_TDISP_START_INTERFACE_RSP) {
if (response->header.message_type != PCI_TDISP_START_INTERFACE_RSP) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.interface_id.function_id != request.header.interface_id.function_id) {
if (response->header.interface_id.function_id != request.header.interface_id.function_id) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

Expand Down
16 changes: 9 additions & 7 deletions library/pci_tdisp_requester_lib/pci_tdisp_req_stop_interface.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright Notice:
* Copyright 2021-2022 DMTF. All rights reserved.
* Copyright 2021-2024 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

Expand Down Expand Up @@ -28,7 +28,8 @@ libspdm_return_t pci_tdisp_stop_interface(const void *pci_doe_context,
libspdm_return_t status;
pci_tdisp_stop_interface_request_t request;
size_t request_size;
pci_tdisp_stop_interface_response_t response;
uint8_t res_buf[LIBTDISP_ERROR_MESSAGE_MAX_SIZE];
pci_tdisp_stop_interface_response_t *response;
size_t response_size;

libspdm_zero_mem (&request, sizeof(request));
Expand All @@ -37,24 +38,25 @@ libspdm_return_t pci_tdisp_stop_interface(const void *pci_doe_context,
request.header.interface_id.function_id = interface_id->function_id;

request_size = sizeof(request);
response_size = sizeof(response);
response = (void *)res_buf;
response_size = sizeof(res_buf);
status = pci_tdisp_send_receive_data(spdm_context, session_id,
&request, request_size,
&response, &response_size);
response, &response_size);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

if (response_size != sizeof(pci_tdisp_stop_interface_response_t)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
}
if (response.header.version != request.header.version) {
if (response->header.version != request.header.version) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.message_type != PCI_TDISP_STOP_INTERFACE_RSP) {
if (response->header.message_type != PCI_TDISP_STOP_INTERFACE_RSP) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}
if (response.header.interface_id.function_id != request.header.interface_id.function_id) {
if (response->header.interface_id.function_id != request.header.interface_id.function_id) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
}

Expand Down
Loading