Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

s390/crash: Use note name macros

Use note name macros to match with the userspace's expectation.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Link: https://lore.kernel.org/r/20250115-elf-v5-5-0f9e55bbb2fc@daynix.com
Signed-off-by: Kees Cook <kees@kernel.org>

authored by

Akihiko Odaki and committed by
Kees Cook
d4a760fb 0de47f28

+23 -39
+23 -39
arch/s390/kernel/crash_dump.c
··· 246 246 } 247 247 EXPORT_SYMBOL_GPL(is_kdump_kernel); 248 248 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 - 258 249 /* 259 250 * Initialize ELF note 260 251 */ ··· 270 279 return PTR_ADD(buf, len); 271 280 } 272 281 273 - static inline void *nt_init(void *buf, Elf64_Word type, void *desc, int d_len) 274 - { 275 - return nt_init_name(buf, type, desc, d_len, nt_name(type)); 276 - } 282 + #define nt_init(buf, type, desc) \ 283 + nt_init_name(buf, NT_ ## type, &(desc), sizeof(desc), NN_ ## type) 277 284 278 285 /* 279 286 * Calculate the size of ELF note ··· 287 298 return size; 288 299 } 289 300 290 - static inline size_t nt_size(Elf64_Word type, int d_len) 291 - { 292 - return nt_size_name(d_len, nt_name(type)); 293 - } 301 + #define nt_size(type, desc) nt_size_name(sizeof(desc), NN_ ## type) 294 302 295 303 /* 296 304 * Fill ELF notes for one CPU with save area registers ··· 308 322 memcpy(&nt_fpregset.fpc, &sa->fpc, sizeof(sa->fpc)); 309 323 memcpy(&nt_fpregset.fprs, &sa->fprs, sizeof(sa->fprs)); 310 324 /* Create ELF notes for the CPU */ 311 - ptr = nt_init(ptr, NT_PRSTATUS, &nt_prstatus, sizeof(nt_prstatus)); 312 - ptr = nt_init(ptr, NT_PRFPREG, &nt_fpregset, sizeof(nt_fpregset)); 313 - ptr = nt_init(ptr, NT_S390_TIMER, &sa->timer, sizeof(sa->timer)); 314 - ptr = nt_init(ptr, NT_S390_TODCMP, &sa->todcmp, sizeof(sa->todcmp)); 315 - ptr = nt_init(ptr, NT_S390_TODPREG, &sa->todpreg, sizeof(sa->todpreg)); 316 - ptr = nt_init(ptr, NT_S390_CTRS, &sa->ctrs, sizeof(sa->ctrs)); 317 - ptr = nt_init(ptr, NT_S390_PREFIX, &sa->prefix, sizeof(sa->prefix)); 325 + ptr = nt_init(ptr, PRSTATUS, nt_prstatus); 326 + ptr = nt_init(ptr, PRFPREG, nt_fpregset); 327 + ptr = nt_init(ptr, S390_TIMER, sa->timer); 328 + ptr = nt_init(ptr, S390_TODCMP, sa->todcmp); 329 + ptr = nt_init(ptr, S390_TODPREG, sa->todpreg); 330 + ptr = nt_init(ptr, S390_CTRS, sa->ctrs); 331 + ptr = nt_init(ptr, S390_PREFIX, sa->prefix); 318 332 if (cpu_has_vx()) { 319 - ptr = nt_init(ptr, NT_S390_VXRS_HIGH, 320 - &sa->vxrs_high, sizeof(sa->vxrs_high)); 321 - ptr = nt_init(ptr, NT_S390_VXRS_LOW, 322 - &sa->vxrs_low, sizeof(sa->vxrs_low)); 333 + ptr = nt_init(ptr, S390_VXRS_HIGH, sa->vxrs_high); 334 + ptr = nt_init(ptr, S390_VXRS_LOW, sa->vxrs_low); 323 335 } 324 336 return ptr; 325 337 } ··· 330 346 struct save_area *sa = NULL; 331 347 size_t size; 332 348 333 - size = nt_size(NT_PRSTATUS, sizeof(struct elf_prstatus)); 334 - size += nt_size(NT_PRFPREG, sizeof(elf_fpregset_t)); 335 - size += nt_size(NT_S390_TIMER, sizeof(sa->timer)); 336 - size += nt_size(NT_S390_TODCMP, sizeof(sa->todcmp)); 337 - size += nt_size(NT_S390_TODPREG, sizeof(sa->todpreg)); 338 - size += nt_size(NT_S390_CTRS, sizeof(sa->ctrs)); 339 - size += nt_size(NT_S390_PREFIX, sizeof(sa->prefix)); 349 + size = nt_size(PRSTATUS, struct elf_prstatus); 350 + size += nt_size(PRFPREG, elf_fpregset_t); 351 + size += nt_size(S390_TIMER, sa->timer); 352 + size += nt_size(S390_TODCMP, sa->todcmp); 353 + size += nt_size(S390_TODPREG, sa->todpreg); 354 + size += nt_size(S390_CTRS, sa->ctrs); 355 + size += nt_size(S390_PREFIX, sa->prefix); 340 356 if (cpu_has_vx()) { 341 - size += nt_size(NT_S390_VXRS_HIGH, sizeof(sa->vxrs_high)); 342 - size += nt_size(NT_S390_VXRS_LOW, sizeof(sa->vxrs_low)); 357 + size += nt_size(S390_VXRS_HIGH, sa->vxrs_high); 358 + size += nt_size(S390_VXRS_LOW, sa->vxrs_low); 343 359 } 344 360 345 361 return size; ··· 355 371 memset(&prpsinfo, 0, sizeof(prpsinfo)); 356 372 prpsinfo.pr_sname = 'R'; 357 373 strcpy(prpsinfo.pr_fname, "vmlinux"); 358 - return nt_init(ptr, NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo)); 374 + return nt_init(ptr, PRPSINFO, prpsinfo); 359 375 } 360 376 361 377 /* ··· 594 610 /* PT_NOTES */ 595 611 size += sizeof(Elf64_Phdr); 596 612 /* nt_prpsinfo */ 597 - size += nt_size(NT_PRPSINFO, sizeof(struct elf_prpsinfo)); 613 + size += nt_size(PRPSINFO, struct elf_prpsinfo); 598 614 /* regsets */ 599 615 size += get_cpu_cnt() * get_cpu_elf_notes_size(); 600 616 /* nt_vmcoreinfo */