Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | From c9188e59fd27d208a975187da285a9b5938bb00d Mon Sep 17 00:00:00 2001 |
| 2 | From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> |
| 3 | Date: Thu, 16 Dec 2021 13:29:58 +0000 |
| 4 | Subject: [PATCH] Add logs to functions in SMM gateway SP |
| 5 | |
| 6 | Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> |
| 7 | |
| 8 | Upstream-Status: Pending [Not submitted to upstream yet] |
| 9 | Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> |
| 10 | |
| 11 | |
| 12 | --- |
| 13 | .../backend/uefi_variable_store.c | 29 +++++++++++++++++-- |
| 14 | .../provider/smm_variable_provider.c | 7 +++-- |
| 15 | 2 files changed, 32 insertions(+), 4 deletions(-) |
| 16 | |
| 17 | diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c |
| 18 | index ed50eaf9..0c371e94 100644 |
| 19 | --- a/components/service/smm_variable/backend/uefi_variable_store.c |
| 20 | +++ b/components/service/smm_variable/backend/uefi_variable_store.c |
| 21 | @@ -11,6 +11,7 @@ |
| 22 | #include "uefi_variable_store.h" |
| 23 | #include "variable_index_iterator.h" |
| 24 | #include "variable_checker.h" |
| 25 | +#include <trace.h> |
| 26 | |
| 27 | /* Private functions */ |
| 28 | static void load_variable_index( |
| 29 | @@ -151,12 +152,15 @@ void uefi_variable_store_set_storage_limits( |
| 30 | size_t total_capacity, |
| 31 | size_t max_variable_size) |
| 32 | { |
| 33 | + EMSG("In func %s\n", __func__); |
| 34 | struct delegate_variable_store *delegate_store = select_delegate_store( |
| 35 | context, |
| 36 | attributes); |
| 37 | |
| 38 | delegate_store->total_capacity = total_capacity; |
| 39 | delegate_store->max_variable_size = max_variable_size; |
| 40 | + EMSG("In func %s total_capacity is %d\n", __func__, total_capacity); |
| 41 | + EMSG("In func %s max_variable_size is %d\n", __func__, max_variable_size); |
| 42 | } |
| 43 | |
| 44 | efi_status_t uefi_variable_store_set_variable( |
| 45 | @@ -265,6 +269,7 @@ efi_status_t uefi_variable_store_get_variable( |
| 46 | size_t max_data_len, |
| 47 | size_t *total_length) |
| 48 | { |
| 49 | + EMSG("In func %s\n", __func__); |
| 50 | efi_status_t status = check_name_terminator(var->Name, var->NameSize); |
| 51 | if (status != EFI_SUCCESS) return status; |
| 52 | |
| 53 | @@ -299,6 +304,7 @@ efi_status_t uefi_variable_store_get_next_variable_name( |
| 54 | size_t max_name_len, |
| 55 | size_t *total_length) |
| 56 | { |
| 57 | + EMSG("In func %s\n", __func__); |
| 58 | efi_status_t status = check_name_terminator(cur->Name, cur->NameSize); |
| 59 | if (status != EFI_SUCCESS) return status; |
| 60 | |
| 61 | @@ -329,6 +335,8 @@ efi_status_t uefi_variable_store_query_variable_info( |
| 62 | struct uefi_variable_store *context, |
| 63 | SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *var_info) |
| 64 | { |
| 65 | + |
| 66 | + EMSG("In func %s\n", __func__); |
| 67 | struct delegate_variable_store *delegate_store = select_delegate_store( |
| 68 | context, |
| 69 | var_info->Attributes); |
| 70 | @@ -337,13 +345,15 @@ efi_status_t uefi_variable_store_query_variable_info( |
| 71 | context, |
| 72 | var_info->Attributes, |
| 73 | delegate_store->storage_backend); |
| 74 | - |
| 75 | + EMSG("In func %s total_used is %d\n", __func__, total_used); |
| 76 | var_info->MaximumVariableSize = delegate_store->max_variable_size; |
| 77 | var_info->MaximumVariableStorageSize = delegate_store->total_capacity; |
| 78 | var_info->RemainingVariableStorageSize = (total_used < delegate_store->total_capacity) ? |
| 79 | delegate_store->total_capacity - total_used : |
| 80 | 0; |
| 81 | - |
| 82 | + EMSG("In func %s var_info->MaximumVariableSize is %d\n", __func__, var_info->MaximumVariableSize); |
| 83 | + EMSG("In func %s var_info->MaximumVariableStorageSize is %d\n", __func__, var_info->MaximumVariableStorageSize); |
| 84 | + EMSG("In func %s var_info->RemainingVariableStorageSize is %d\n", __func__, var_info->RemainingVariableStorageSize); |
| 85 | return EFI_SUCCESS; |
| 86 | } |
| 87 | |
| 88 | @@ -358,6 +368,7 @@ efi_status_t uefi_variable_store_set_var_check_property( |
| 89 | struct uefi_variable_store *context, |
| 90 | const SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY *property) |
| 91 | { |
| 92 | + EMSG("In func %s\n", __func__); |
| 93 | efi_status_t status = check_name_terminator(property->Name, property->NameSize); |
| 94 | if (status != EFI_SUCCESS) return status; |
| 95 | |
| 96 | @@ -404,6 +415,7 @@ efi_status_t uefi_variable_store_get_var_check_property( |
| 97 | struct uefi_variable_store *context, |
| 98 | SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY *property) |
| 99 | { |
| 100 | + EMSG("In func %s\n", __func__); |
| 101 | efi_status_t status = check_name_terminator(property->Name, property->NameSize); |
| 102 | if (status != EFI_SUCCESS) return status; |
| 103 | |
| 104 | @@ -430,6 +442,7 @@ efi_status_t uefi_variable_store_get_var_check_property( |
| 105 | static void load_variable_index( |
| 106 | struct uefi_variable_store *context) |
| 107 | { |
| 108 | + EMSG("In func %s\n", __func__); |
| 109 | struct storage_backend *persistent_store = context->persistent_store.storage_backend; |
| 110 | |
| 111 | if (persistent_store) { |
| 112 | @@ -444,6 +457,7 @@ static void load_variable_index( |
| 113 | context->index_sync_buffer_size, |
| 114 | context->index_sync_buffer, |
| 115 | &data_len); |
| 116 | + EMSG("In func %s get status is %d\n", __func__, psa_status); |
| 117 | |
| 118 | if (psa_status == PSA_SUCCESS) { |
| 119 | |
| 120 | @@ -455,6 +469,7 @@ static void load_variable_index( |
| 121 | static efi_status_t sync_variable_index( |
| 122 | struct uefi_variable_store *context) |
| 123 | { |
| 124 | + EMSG("In func %s\n", __func__); |
| 125 | efi_status_t status = EFI_SUCCESS; |
| 126 | |
| 127 | /* Sync the varibale index to storage if anything is dirty */ |
| 128 | @@ -479,6 +494,7 @@ static efi_status_t sync_variable_index( |
| 129 | data_len, |
| 130 | context->index_sync_buffer, |
| 131 | PSA_STORAGE_FLAG_NONE); |
| 132 | + EMSG("In func %s set status is %d\n", __func__, psa_status); |
| 133 | |
| 134 | status = psa_to_efi_storage_status(psa_status); |
| 135 | } |
| 136 | @@ -490,6 +506,7 @@ static efi_status_t sync_variable_index( |
| 137 | static efi_status_t check_capabilities( |
| 138 | const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *var) |
| 139 | { |
| 140 | + EMSG("In func %s\n", __func__); |
| 141 | efi_status_t status = EFI_SUCCESS; |
| 142 | |
| 143 | /* Check if any unsupported variable attributes have been requested */ |
| 144 | @@ -551,6 +568,7 @@ static efi_status_t store_variable_data( |
| 145 | const struct variable_info *info, |
| 146 | const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *var) |
| 147 | { |
| 148 | + EMSG("In func %s\n", __func__); |
| 149 | psa_status_t psa_status = PSA_SUCCESS; |
| 150 | size_t data_len = var->DataSize; |
| 151 | const uint8_t *data = (const uint8_t*)var + |
| 152 | @@ -599,6 +617,7 @@ static efi_status_t remove_variable_data( |
| 153 | struct uefi_variable_store *context, |
| 154 | const struct variable_info *info) |
| 155 | { |
| 156 | + EMSG("In func %s\n", __func__); |
| 157 | psa_status_t psa_status = PSA_SUCCESS; |
| 158 | |
| 159 | if (info->is_variable_set) { |
| 160 | @@ -613,6 +632,7 @@ static efi_status_t remove_variable_data( |
| 161 | delegate_store->storage_backend->context, |
| 162 | context->owner_id, |
| 163 | info->metadata.uid); |
| 164 | + EMSG("In func %s status is %d\n", __func__, psa_status); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | @@ -625,6 +645,7 @@ static efi_status_t load_variable_data( |
| 169 | SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *var, |
| 170 | size_t max_data_len) |
| 171 | { |
| 172 | + EMSG("In func %s\n", __func__); |
| 173 | psa_status_t psa_status = PSA_SUCCESS; |
| 174 | size_t data_len = 0; |
| 175 | uint8_t *data = (uint8_t*)var + |
| 176 | @@ -644,6 +665,7 @@ static efi_status_t load_variable_data( |
| 177 | max_data_len, |
| 178 | data, |
| 179 | &data_len); |
| 180 | + EMSG("In func %s get status is %d\n", __func__, psa_status); |
| 181 | |
| 182 | var->DataSize = data_len; |
| 183 | } |
| 184 | @@ -771,6 +793,7 @@ static void purge_orphan_index_entries( |
| 185 | context->owner_id, |
| 186 | info->metadata.uid, |
| 187 | &storage_info); |
| 188 | + EMSG("In func %s get status is %d\n", __func__, psa_status); |
| 189 | |
| 190 | if (psa_status != PSA_SUCCESS) { |
| 191 | |
| 192 | @@ -802,6 +825,7 @@ static size_t space_used( |
| 193 | uint32_t attributes, |
| 194 | struct storage_backend *storage_backend) |
| 195 | { |
| 196 | + EMSG("In func %s\n", __func__); |
| 197 | if (!storage_backend) return 0; |
| 198 | |
| 199 | size_t total_used = 0; |
| 200 | @@ -823,6 +847,7 @@ static size_t space_used( |
| 201 | context->owner_id, |
| 202 | info->metadata.uid, |
| 203 | &storage_info); |
| 204 | + EMSG("In func %s get status is %d\n", __func__, psa_status); |
| 205 | |
| 206 | if (psa_status == PSA_SUCCESS) total_used += storage_info.size; |
| 207 | } |
| 208 | diff --git a/components/service/smm_variable/provider/smm_variable_provider.c b/components/service/smm_variable/provider/smm_variable_provider.c |
| 209 | index 52e68d09..1f362c17 100644 |
| 210 | --- a/components/service/smm_variable/provider/smm_variable_provider.c |
| 211 | +++ b/components/service/smm_variable/provider/smm_variable_provider.c |
| 212 | @@ -9,6 +9,7 @@ |
| 213 | #include <protocols/service/smm_variable/smm_variable_proto.h> |
| 214 | #include <protocols/rpc/common/packed-c/status.h> |
| 215 | #include "smm_variable_provider.h" |
| 216 | +#include <trace.h> |
| 217 | |
| 218 | /* Service request handlers */ |
| 219 | static rpc_status_t get_variable_handler(void *context, struct call_req *req); |
| 220 | @@ -252,17 +253,18 @@ static rpc_status_t set_variable_handler(void *context, struct call_req* req) |
| 221 | |
| 222 | static rpc_status_t query_variable_info_handler(void *context, struct call_req* req) |
| 223 | { |
| 224 | + EMSG("In func %s \n", __func__); |
| 225 | efi_status_t efi_status = EFI_INVALID_PARAMETER; |
| 226 | struct smm_variable_provider *this_instance = (struct smm_variable_provider*)context; |
| 227 | |
| 228 | const struct call_param_buf *req_buf = call_req_get_req_buf(req); |
| 229 | - |
| 230 | + EMSG("In func %s sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO) is %d\n", __func__, sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO)); |
| 231 | if (req_buf->data_len >= sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO)) { |
| 232 | |
| 233 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 234 | |
| 235 | if (resp_buf->size >= req_buf->data_len) { |
| 236 | - |
| 237 | + |
| 238 | memmove(resp_buf->data, req_buf->data, req_buf->data_len); |
| 239 | |
| 240 | efi_status = uefi_variable_store_query_variable_info( |
| 241 | @@ -272,6 +274,7 @@ static rpc_status_t query_variable_info_handler(void *context, struct call_req* |
| 242 | if (efi_status == EFI_SUCCESS) { |
| 243 | |
| 244 | resp_buf->data_len = sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO); |
| 245 | + EMSG("In func %s resp_buf->data_len is %d\n", __func__, resp_buf->data_len); |
| 246 | } |
| 247 | } |
| 248 | else { |