Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65911c8e authored by Vaibhav Agrawal's avatar Vaibhav Agrawal Committed by Nitin LNU
Browse files

tzlog: update struct to get normal and fatal diag logs



Add support and update struct to get tz diag logs
in two different chunks i.e. entire logs or fatal
logs.

Test: 1. Basic Bootup with all subsystems out of
         reset on secboot device
      2. SSR on secboot device (Modem, ADSP, CDSP)
      3. All flags set in APDP except JTAG
      4. All flags set to 0 in APDP
      5. Only offline dump flag set in APDP
      6. Only NS dump flag set in APDP
      7. Only Enable Logs flag set in APDP

Change-Id: Idea5ebdf6c558b4a2e26031334f47eb7914a0615
Signed-off-by: default avatarVaibhav Agrawal <vagrawa@codeaurora.org>
parent 7dec09d8
Loading
Loading
Loading
Loading
+97 −24
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#define TZBSP_FVER_MINOR_SHIFT          12
#define TZBSP_DIAG_MAJOR_VERSION_V9     9
#define TZBSP_DIAG_MINOR_VERSION_V2     2
#define TZBSP_DIAG_MINOR_VERSION_V21     3

/* TZ Version Id */
#define QCOM_SCM_FEAT_LOG_ID            0x0a
@@ -202,6 +203,34 @@ struct tzdbg_log_v2_t {
	uint8_t	log_buf[];
};

struct tzbsp_encr_info_for_log_chunk_t {
	uint32_t size_to_encr;
	uint8_t nonce[TZBSP_NONCE_LEN];
	uint8_t tag[TZBSP_TAG_LEN];
};

/*
 * Only `ENTIRE_LOG` will be used unless the
 * "OEM_tz_num_of_diag_log_chunks_to_encr" devcfg field >= 2.
 * If this is true, the diag log will be encrypted in two
 * separate chunks: a smaller chunk containing only error
 * fatal logs and a bigger "rest of the log" chunk. In this
 * case, `ERR_FATAL_LOG_CHUNK` and `BIG_LOG_CHUNK` will be
 * used instead of `ENTIRE_LOG`.
 */
enum tzbsp_encr_info_for_log_chunks_idx_t {
	BIG_LOG_CHUNK = 0,
	ENTIRE_LOG = 1,
	ERR_FATAL_LOG_CHUNK = 1,
	MAX_NUM_OF_CHUNKS,
};

struct tzbsp_encr_info_t {
	uint32_t num_of_chunks;
	struct tzbsp_encr_info_for_log_chunk_t chunks[MAX_NUM_OF_CHUNKS];
	uint8_t key[TZBSP_AES_256_ENCRYPTED_KEY_SIZE];
};

/*
 * Diagnostic Table
 * Note: This is the reference data structure for tz diagnostic table
@@ -243,6 +272,12 @@ struct tzdbg_t {
	/* Offset for Wakeup info */
	uint32_t wakeup_info_off;

	union {
		/* The elements in below structure have to be used for TZ where
		 * diag version = TZBSP_DIAG_MINOR_VERSION_V2
		 */
		struct {

			/*
			 * VMID to EE Mapping
			 */
@@ -254,18 +289,54 @@ struct tzdbg_t {
			/*
			 * Reset Info
			 */
	struct tzdbg_reset_info_t reset_info[TZBSP_MAX_CPU_COUNT];
			struct tzdbg_reset_info_t
				reset_info[TZBSP_MAX_CPU_COUNT];

			uint32_t num_interrupts;
			struct tzdbg_int_t  int_info[TZBSP_DIAG_INT_NUM];

			/* Wake up info */
	struct tzbsp_diag_wakeup_info_t  wakeup_info[TZBSP_MAX_CPU_COUNT];
			struct tzbsp_diag_wakeup_info_t
				wakeup_info[TZBSP_MAX_CPU_COUNT];

			uint8_t key[TZBSP_AES_256_ENCRYPTED_KEY_SIZE];

			uint8_t nonce[TZBSP_NONCE_LEN];

			uint8_t tag[TZBSP_TAG_LEN];
		};
		/* The elements in below structure have to be used for TZ where
		 * diag version = TZBSP_DIAG_MINOR_VERSION_V21
		 */
		struct {

			uint32_t encr_info_for_log_off;

			/*
			 * VMID to EE Mapping
			 */
			struct tzdbg_vmid_t
				vmid_info_v2[TZBSP_DIAG_NUM_OF_VMID];
			/*
			 * Boot Info
			 */
			struct tzdbg_boot_info_t
				boot_info_v2[TZBSP_MAX_CPU_COUNT];
			/*
			 * Reset Info
			 */
			struct tzdbg_reset_info_t
				reset_info_v2[TZBSP_MAX_CPU_COUNT];

			uint32_t num_interrupts_v2;
			struct tzdbg_int_t int_info_v2[TZBSP_DIAG_INT_NUM];

			/* Wake up info */
			struct tzbsp_diag_wakeup_info_t
				wakeup_info_v2[TZBSP_MAX_CPU_COUNT];

			struct tzbsp_encr_info_t encr_info_for_log;
		};
	};

	/*
	 * We need at least 2K for the ring buffer
@@ -1455,8 +1526,10 @@ static int tzdbg_get_tz_version(void)
	if (
	(((version >> TZBSP_FVER_MAJOR_SHIFT) & TZBSP_FVER_MAJOR_MINOR_MASK)
			== TZBSP_DIAG_MAJOR_VERSION_V9) &&
	((((version >> TZBSP_FVER_MINOR_SHIFT) & TZBSP_FVER_MAJOR_MINOR_MASK)
			== TZBSP_DIAG_MINOR_VERSION_V2) ||
	(((version >> TZBSP_FVER_MINOR_SHIFT) & TZBSP_FVER_MAJOR_MINOR_MASK)
			== TZBSP_DIAG_MINOR_VERSION_V2))
			== TZBSP_DIAG_MINOR_VERSION_V21)))
		tzdbg.is_enlarged_buf = true;
	else
		tzdbg.is_enlarged_buf = false;