Skip to content

Commit d4a760f

Browse files
akihikodakikees
authored andcommitted
s390/crash: Use note name macros
Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki <[email protected]> Acked-by: Heiko Carstens <[email protected]> Reviewed-by: Dave Martin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 0de47f2 commit d4a760f

File tree

1 file changed

+23
-39
lines changed

1 file changed

+23
-39
lines changed

arch/s390/kernel/crash_dump.c

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,6 @@ bool is_kdump_kernel(void)
246246
}
247247
EXPORT_SYMBOL_GPL(is_kdump_kernel);
248248

249-
static const char *nt_name(Elf64_Word type)
250-
{
251-
const char *name = "LINUX";
252-
253-
if (type == NT_PRPSINFO || type == NT_PRSTATUS || type == NT_PRFPREG)
254-
name = KEXEC_CORE_NOTE_NAME;
255-
return name;
256-
}
257-
258249
/*
259250
* Initialize ELF note
260251
*/
@@ -279,10 +270,8 @@ static void *nt_init_name(void *buf, Elf64_Word type, void *desc, int d_len,
279270
return PTR_ADD(buf, len);
280271
}
281272

282-
static inline void *nt_init(void *buf, Elf64_Word type, void *desc, int d_len)
283-
{
284-
return nt_init_name(buf, type, desc, d_len, nt_name(type));
285-
}
273+
#define nt_init(buf, type, desc) \
274+
nt_init_name(buf, NT_ ## type, &(desc), sizeof(desc), NN_ ## type)
286275

287276
/*
288277
* Calculate the size of ELF note
@@ -298,10 +287,7 @@ static size_t nt_size_name(int d_len, const char *name)
298287
return size;
299288
}
300289

301-
static inline size_t nt_size(Elf64_Word type, int d_len)
302-
{
303-
return nt_size_name(d_len, nt_name(type));
304-
}
290+
#define nt_size(type, desc) nt_size_name(sizeof(desc), NN_ ## type)
305291

306292
/*
307293
* Fill ELF notes for one CPU with save area registers
@@ -322,18 +308,16 @@ static void *fill_cpu_elf_notes(void *ptr, int cpu, struct save_area *sa)
322308
memcpy(&nt_fpregset.fpc, &sa->fpc, sizeof(sa->fpc));
323309
memcpy(&nt_fpregset.fprs, &sa->fprs, sizeof(sa->fprs));
324310
/* Create ELF notes for the CPU */
325-
ptr = nt_init(ptr, NT_PRSTATUS, &nt_prstatus, sizeof(nt_prstatus));
326-
ptr = nt_init(ptr, NT_PRFPREG, &nt_fpregset, sizeof(nt_fpregset));
327-
ptr = nt_init(ptr, NT_S390_TIMER, &sa->timer, sizeof(sa->timer));
328-
ptr = nt_init(ptr, NT_S390_TODCMP, &sa->todcmp, sizeof(sa->todcmp));
329-
ptr = nt_init(ptr, NT_S390_TODPREG, &sa->todpreg, sizeof(sa->todpreg));
330-
ptr = nt_init(ptr, NT_S390_CTRS, &sa->ctrs, sizeof(sa->ctrs));
331-
ptr = nt_init(ptr, NT_S390_PREFIX, &sa->prefix, sizeof(sa->prefix));
311+
ptr = nt_init(ptr, PRSTATUS, nt_prstatus);
312+
ptr = nt_init(ptr, PRFPREG, nt_fpregset);
313+
ptr = nt_init(ptr, S390_TIMER, sa->timer);
314+
ptr = nt_init(ptr, S390_TODCMP, sa->todcmp);
315+
ptr = nt_init(ptr, S390_TODPREG, sa->todpreg);
316+
ptr = nt_init(ptr, S390_CTRS, sa->ctrs);
317+
ptr = nt_init(ptr, S390_PREFIX, sa->prefix);
332318
if (cpu_has_vx()) {
333-
ptr = nt_init(ptr, NT_S390_VXRS_HIGH,
334-
&sa->vxrs_high, sizeof(sa->vxrs_high));
335-
ptr = nt_init(ptr, NT_S390_VXRS_LOW,
336-
&sa->vxrs_low, sizeof(sa->vxrs_low));
319+
ptr = nt_init(ptr, S390_VXRS_HIGH, sa->vxrs_high);
320+
ptr = nt_init(ptr, S390_VXRS_LOW, sa->vxrs_low);
337321
}
338322
return ptr;
339323
}
@@ -346,16 +330,16 @@ static size_t get_cpu_elf_notes_size(void)
346330
struct save_area *sa = NULL;
347331
size_t size;
348332

349-
size = nt_size(NT_PRSTATUS, sizeof(struct elf_prstatus));
350-
size += nt_size(NT_PRFPREG, sizeof(elf_fpregset_t));
351-
size += nt_size(NT_S390_TIMER, sizeof(sa->timer));
352-
size += nt_size(NT_S390_TODCMP, sizeof(sa->todcmp));
353-
size += nt_size(NT_S390_TODPREG, sizeof(sa->todpreg));
354-
size += nt_size(NT_S390_CTRS, sizeof(sa->ctrs));
355-
size += nt_size(NT_S390_PREFIX, sizeof(sa->prefix));
333+
size = nt_size(PRSTATUS, struct elf_prstatus);
334+
size += nt_size(PRFPREG, elf_fpregset_t);
335+
size += nt_size(S390_TIMER, sa->timer);
336+
size += nt_size(S390_TODCMP, sa->todcmp);
337+
size += nt_size(S390_TODPREG, sa->todpreg);
338+
size += nt_size(S390_CTRS, sa->ctrs);
339+
size += nt_size(S390_PREFIX, sa->prefix);
356340
if (cpu_has_vx()) {
357-
size += nt_size(NT_S390_VXRS_HIGH, sizeof(sa->vxrs_high));
358-
size += nt_size(NT_S390_VXRS_LOW, sizeof(sa->vxrs_low));
341+
size += nt_size(S390_VXRS_HIGH, sa->vxrs_high);
342+
size += nt_size(S390_VXRS_LOW, sa->vxrs_low);
359343
}
360344

361345
return size;
@@ -371,7 +355,7 @@ static void *nt_prpsinfo(void *ptr)
371355
memset(&prpsinfo, 0, sizeof(prpsinfo));
372356
prpsinfo.pr_sname = 'R';
373357
strcpy(prpsinfo.pr_fname, "vmlinux");
374-
return nt_init(ptr, NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo));
358+
return nt_init(ptr, PRPSINFO, prpsinfo);
375359
}
376360

377361
/*
@@ -610,7 +594,7 @@ static size_t get_elfcorehdr_size(int phdr_count)
610594
/* PT_NOTES */
611595
size += sizeof(Elf64_Phdr);
612596
/* nt_prpsinfo */
613-
size += nt_size(NT_PRPSINFO, sizeof(struct elf_prpsinfo));
597+
size += nt_size(PRPSINFO, struct elf_prpsinfo);
614598
/* regsets */
615599
size += get_cpu_cnt() * get_cpu_elf_notes_size();
616600
/* nt_vmcoreinfo */

0 commit comments

Comments
 (0)