From 885405e3212fe91af42bdfb6a3376cead616a92c Mon Sep 17 00:00:00 2001 From: Aruna Balakrishnaiah Date: Wed, 13 Aug 2014 14:01:46 +0530 Subject: attn: Add git version and backtrace details to user data For better debugability, the patch adds git version and backtrace details to user data section (along with file info which was already present). After adding required details TermImmedData looks like: TermImmedData | | 00000000 63386631 6639322D 64697274 793A0000 c8f1f92-dirty:.. | | 00000010 00000000 00000000 00000000 00000000 ................ | | 00000020 00000000 00000000 43505520 30303030 ........CPU 0000 | | 00000030 30303264 20426163 6B747261 63653A0A 002d Backtrace:. | | 00000040 20533A20 30303030 30303030 33316162 S: 0000000031ab | | 00000050 36626130 20523A20 30303030 30303030 6ba0 R: 00000000 | | 00000060 33303031 33306238 0A20533A 20303030 300130b8. S: 000 | | 00000070 30303030 30333161 62366334 3020523A 0000031ab6c40 R: | | 00000080 20303030 30303030 30333030 34623738 000000003004b78 | | 00000090 380A2053 3A203030 30303030 30303331 8. S: 0000000031 | | 000000A0 61623663 63302052 3A203030 30303030 ab6cc0 R: 000000 | | 000000B0 30303330 30313736 31300A20 533A2030 0030017610. S: 0 | | 000000C0 30303030 30303033 31616236 64343020 000000031ab6d40 | | 000000D0 523A2030 30303030 30303033 30303035 R: 0000000030005 | | 000000E0 3133340A 20533A20 30303030 30303030 134. S: 00000000 | | 000000F0 33316162 36663030 20523A20 30303030 31ab6f00 R: 0000 | | 00000100 30303030 33303030 32353534 0A000000 000030002554.... | | 00000110 00000000 00000000 00000000 00000000 ................ | | 00000120 00000000 00000000 00000000 00000000 ................ | | 00000130 00000000 00000000 00000000 00000000 ................ | | 00000140 00000000 00000000 00000000 00000000 ................ | | 00000150 00000000 00000000 00000000 00000000 ................ | | 00000160 00000000 00000000 00000000 00000000 ................ | | 00000170 00000000 00000000 00000000 00000000 ................ | | 00000180 00000000 00000000 00000000 00000000 ................ | | 00000190 00000000 00000000 00000000 00000000 ................ | | 000001A0 00000000 00000000 00000000 00000000 ................ | | 000001B0 00000000 00000000 00000000 00000000 ................ | | 000001C0 00000000 00000000 00000000 636F7265 ............core | | 000001D0 2F6F7061 6C2E633A 3233383A 30000000 /opal.c:238:0... | |------------------------------------------------------------------------------| Signed-off-by: Aruna Balakrishnaiah Signed-off-by: Benjamin Herrenschmidt --- hw/fsp/fsp-attn.c | 8 ++++++-- include/fsp-attn.h | 18 ++++++++++++++++-- libc/include/assert.h | 3 ++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/hw/fsp/fsp-attn.c b/hw/fsp/fsp-attn.c index 07c99c0..9edc920 100644 --- a/hw/fsp/fsp-attn.c +++ b/hw/fsp/fsp-attn.c @@ -95,8 +95,12 @@ void update_sp_attn_area(const char *msg) ti_attn->src_word[0] = (uint32_t)generate_hex_word((uint64_t)__builtin_return_address(0)); - ti_attn->msg_len = strlen(msg); - sprintf(ti_attn->msg, "%s", msg); + snprintf(ti_attn->msg.gitid, GITID_LEN, "%s", gitid); + __backtrace(ti_attn->msg.bt_buf, BT_FRAME_LEN); + snprintf(ti_attn->msg.file_info, FILE_INFO_LEN, "%s", msg); + + ti_attn->msg_len = GITID_LEN + BT_FRAME_LEN + + strlen(ti_attn->msg.file_info); } /* Intialises SP attention area */ diff --git a/include/fsp-attn.h b/include/fsp-attn.h index 0149b7c..947c49f 100644 --- a/include/fsp-attn.h +++ b/include/fsp-attn.h @@ -57,6 +57,20 @@ struct sp_attn_area { #define SRC_LEN 32 /* Max limit of user data size is 940 (due to attention area size) */ #define TI_MSG_LEN 940 + +/* Maximum sapphire version length (approx) */ +#define GITID_LEN 40 +/* Upto 10 frames each of length 40 bytes + header = 430 bytes */ +#define BT_FRAME_LEN 430 +/* File info length : Use the rest of the memory for file details */ +#define FILE_INFO_LEN (TI_MSG_LEN - GITID_LEN - BT_FRAME_LEN) + +struct user_data { + char gitid[GITID_LEN]; + char bt_buf[BT_FRAME_LEN]; + char file_info[FILE_INFO_LEN]; +} __packed; + /* Terminate Immediate Attention */ struct ti_attn { /* Command valid */ @@ -84,8 +98,8 @@ struct ti_attn { /* ASCII data */ char src[SRC_LEN]; uint32_t msg_len; - /* User data: Simple error message */ - char msg[TI_MSG_LEN]; + /* User data: Debug details */ + struct user_data msg; } __packed __align(ATTN_AREA_SZ); /* Hypervisor Service Routine Data area: Structure is not used as of today, diff --git a/libc/include/assert.h b/libc/include/assert.h index fbfb2cc..68f01ab 100644 --- a/libc/include/assert.h +++ b/libc/include/assert.h @@ -18,7 +18,8 @@ extern void update_sp_attn_area(const char *msg); #define assert(cond) \ do { if (!(cond)) { \ update_sp_attn_area(__FILE__ \ - ":" stringify(__LINE__)); \ + ":" stringify(__LINE__) \ + ":" stringify(cond)); \ assert_fail(__FILE__ \ ":" stringify(__LINE__) \ ":" stringify(cond)); } \ -- cgit v1.1