Commit 4e59f060 authored by Edwin Peer's avatar Edwin Peer Committed by David S. Miller

bnxt_en: extract coredump command line from current task

Tools other than 'ethtool -w' may be used to produce a coredump. For
devlink health, such dumps could even be driver initiated in response
to a health event. In these cases, the kernel thread information will
be placed in the coredump record instead.

v2: use min_t() instead of min() to fix the mismatched type warning
Signed-off-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 80194db9
......@@ -194,6 +194,30 @@ bnxt_fill_coredump_seg_hdr(struct bnxt *bp,
seg_hdr->instance = cpu_to_le32(instance);
}
static void bnxt_fill_cmdline(struct bnxt_coredump_record *record)
{
struct mm_struct *mm = current->mm;
int i, len, last = 0;
if (mm) {
len = min_t(int, mm->arg_end - mm->arg_start,
sizeof(record->commandline) - 1);
if (len && !copy_from_user(record->commandline,
(char __user *)mm->arg_start, len)) {
for (i = 0; i < len; i++) {
if (record->commandline[i])
last = i;
else
record->commandline[i] = ' ';
}
record->commandline[last + 1] = 0;
return;
}
}
strscpy(record->commandline, current->comm, TASK_COMM_LEN);
}
static void
bnxt_fill_coredump_record(struct bnxt *bp, struct bnxt_coredump_record *record,
time64_t start, s16 start_utc, u16 total_segs,
......@@ -219,7 +243,7 @@ bnxt_fill_coredump_record(struct bnxt *bp, struct bnxt_coredump_record *record,
record->minute = cpu_to_le16(tm.tm_min);
record->second = cpu_to_le16(tm.tm_sec);
record->utc_bias = cpu_to_le16(start_utc);
strcpy(record->commandline, "ethtool -w");
bnxt_fill_cmdline(record);
record->total_segments = cpu_to_le32(total_segs);
if (sscanf(utsname()->release, "%u.%u", &os_ver_major, &os_ver_minor) != 2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment