diff options
author | PixelBot AutoMerger <android-nexus-securitybot@system.gserviceaccount.com> | 2023-06-18 18:29:34 -0700 |
---|---|---|
committer | SecurityBot <android-nexus-securitybot@system.gserviceaccount.com> | 2023-06-18 18:29:34 -0700 |
commit | 17e0e8efc3a2c08836d103fdaf09fa8d63203e4b (patch) | |
tree | b569abb7f271b9cbe0037d2ff7243b8e42171765 | |
parent | 98754128a11ea7803d56e5527d31892463d97195 (diff) | |
parent | 04310e66ecd292563b1b8859c7550f1c67322dd2 (diff) | |
download | aoc-17e0e8efc3a2c08836d103fdaf09fa8d63203e4b.tar.gz |
Merge android13-gs-pixel-5.10-udc into android13-gs-pixel-5.10-udc-qpr1
SBMerger: 526756187
Change-Id: I9e65ac9827d1bc59c0f760fb4e117d96026c276a
Signed-off-by: SecurityBot <android-nexus-securitybot@system.gserviceaccount.com>
-rw-r--r-- | aoc.c | 50 |
1 files changed, 28 insertions, 22 deletions
@@ -2554,14 +2554,16 @@ static irqreturn_t watchdog_int_handler(int irq, void *dev) return IRQ_HANDLED; } -static int compute_section_offset(struct aoc_ramdump_header *ramdump_header, int section_index) +static struct aoc_section_header *find_ramdump_section(struct aoc_ramdump_header + *ramdump_header, int section_type) { - int i, crash_info_section_offset = RAMDUMP_SECTION_SRAM_OFFSET; + int i; - for (i = 0; i < section_index; i++) - crash_info_section_offset += ramdump_header->sections[i].size; + for (i = 0; i < ramdump_header->num_sections; i++) + if (ramdump_header->sections[i].type == section_type) + return &ramdump_header->sections[i]; - return crash_info_section_offset; + return NULL; } static void aoc_watchdog(struct work_struct *work) @@ -2586,10 +2588,9 @@ static void aoc_watchdog(struct work_struct *work) int sscd_rc; char crash_info[RAMDUMP_SECTION_CRASH_INFO_SIZE]; int restart_rc; - u32 section_flags; bool ap_reset = false; - int crash_info_section_offset = compute_section_offset(ramdump_header, - RAMDUMP_SECTION_CRASH_INFO_INDEX); + struct aoc_section_header *crash_info_section = + find_ramdump_section(ramdump_header, SECTION_TYPE_CRASH_INFO); prvdata->total_restarts++; @@ -2644,16 +2645,23 @@ static void aoc_watchdog(struct work_struct *work) } if (!ramdump_header->valid) { - const char *crash_reason = (const char *)ramdump_header + - crash_info_section_offset; - bool crash_reason_valid = (strnlen(crash_reason, - sizeof(crash_info)) != 0); - dev_err(prvdata->dev, "aoc coredump timed out, coredump only contains DRAM\n"); - snprintf(crash_info, sizeof(crash_info), - "AoC watchdog : %s (incomplete %u:%u)", - crash_reason_valid ? crash_reason : "unknown reason", - ramdump_header->breadcrumbs[0], ramdump_header->breadcrumbs[1]); + if (crash_info_section) { + const char *crash_reason = (const char *)ramdump_header + + crash_info_section->offset; + bool crash_reason_valid = (strnlen(crash_reason, + sizeof(crash_info)) != 0); + + snprintf(crash_info, sizeof(crash_info), + "AoC watchdog : %s (incomplete %u:%u)", + crash_reason_valid ? crash_reason : "unknown reason", + ramdump_header->breadcrumbs[0], ramdump_header->breadcrumbs[1]); + } else { + dev_err(prvdata->dev, "could not find crash info section in aoc coredump header"); + snprintf(crash_info, sizeof(crash_info), + "AoC watchdog : unknown reason (incomplete %u:%u)", + ramdump_header->breadcrumbs[0], ramdump_header->breadcrumbs[1]); + } } if (ramdump_header->valid && memcmp(ramdump_header, RAMDUMP_MAGIC, sizeof(RAMDUMP_MAGIC))) { @@ -2681,11 +2689,9 @@ static void aoc_watchdog(struct work_struct *work) } if (ramdump_header->valid) { - const char *crash_reason = (const char *)ramdump_header + - crash_info_section_offset; - - section_flags = ramdump_header->sections[RAMDUMP_SECTION_CRASH_INFO_INDEX].flags; - if (section_flags & RAMDUMP_FLAG_VALID) { + if (crash_info_section && crash_info_section->flags & RAMDUMP_FLAG_VALID) { + const char *crash_reason = (const char *)ramdump_header + + crash_info_section->offset; dev_info(prvdata->dev, "aoc coredump has valid coredump header, crash reason [%s]", crash_reason); strscpy(crash_info, crash_reason, sizeof(crash_info)); |