@@ -246,15 +246,6 @@ bool is_kdump_kernel(void)
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
*/
@@ -279,10 +270,8 @@ static void *nt_init_name(void *buf, Elf64_Word type, void *desc, int d_len,
279
270
return PTR_ADD (buf , len );
280
271
}
281
272
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)
286
275
287
276
/*
288
277
* Calculate the size of ELF note
@@ -298,10 +287,7 @@ static size_t nt_size_name(int d_len, const char *name)
298
287
return size ;
299
288
}
300
289
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)
305
291
306
292
/*
307
293
* 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)
322
308
memcpy (& nt_fpregset .fpc , & sa -> fpc , sizeof (sa -> fpc ));
323
309
memcpy (& nt_fpregset .fprs , & sa -> fprs , sizeof (sa -> fprs ));
324
310
/* 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 );
332
318
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 );
337
321
}
338
322
return ptr ;
339
323
}
@@ -346,16 +330,16 @@ static size_t get_cpu_elf_notes_size(void)
346
330
struct save_area * sa = NULL ;
347
331
size_t size ;
348
332
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 );
356
340
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 );
359
343
}
360
344
361
345
return size ;
@@ -371,7 +355,7 @@ static void *nt_prpsinfo(void *ptr)
371
355
memset (& prpsinfo , 0 , sizeof (prpsinfo ));
372
356
prpsinfo .pr_sname = 'R' ;
373
357
strcpy (prpsinfo .pr_fname , "vmlinux" );
374
- return nt_init (ptr , NT_PRPSINFO , & prpsinfo , sizeof ( prpsinfo ) );
358
+ return nt_init (ptr , PRPSINFO , prpsinfo );
375
359
}
376
360
377
361
/*
@@ -610,7 +594,7 @@ static size_t get_elfcorehdr_size(int phdr_count)
610
594
/* PT_NOTES */
611
595
size += sizeof (Elf64_Phdr );
612
596
/* nt_prpsinfo */
613
- size += nt_size (NT_PRPSINFO , sizeof ( struct elf_prpsinfo ) );
597
+ size += nt_size (PRPSINFO , struct elf_prpsinfo );
614
598
/* regsets */
615
599
size += get_cpu_cnt () * get_cpu_elf_notes_size ();
616
600
/* nt_vmcoreinfo */
0 commit comments