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

Use ELF_BASE_PLATFORM to pass ISA level

Some userland application/program runtime/dynamic loaded need to
know about the current ISA level to use the best runtime.
While kernel doesn't provides this info.

ELF_PLATFORM only provides some info about the CPU, with very few info,
for example, the value is "mips" for both 24Kc and P6600.

Currently ELF_BASE_PLATFORM is not used by MIPS (only by powerpc).
So we cant set its value as:
mips2, mips3, mips4, mips5,
mips32, mips32r2, mips32r6
mips64, mips64r2, mips64r6
Then in userland, we can get it by:
getauxval(AT_BASE_PLATFORM)

The only problem is that it seems has different defination than ppc:
on ppc, it is the mircoarchitecture
while now we use it as ISA level on MIPS.

Signed-off-by: YunQiang Su <syq@debian.org>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

YunQiang Su and committed by
Thomas Bogendoerfer
e585b768 be280764

+21
+3
arch/mips/include/asm/elf.h
··· 445 445 #define ELF_PLATFORM __elf_platform 446 446 extern const char *__elf_platform; 447 447 448 + #define ELF_BASE_PLATFORM __elf_base_platform 449 + extern const char *__elf_base_platform; 450 + 448 451 /* 449 452 * See comments in asm-alpha/elf.h, this is the same thing 450 453 * on the MIPS.
+18
arch/mips/kernel/cpu-probe.c
··· 513 513 __elf_platform = plat; 514 514 } 515 515 516 + static inline void set_elf_base_platform(const char *plat) 517 + { 518 + if (__elf_base_platform == NULL) { 519 + __elf_base_platform = plat; 520 + } 521 + } 522 + 516 523 static inline void cpu_probe_vmbits(struct cpuinfo_mips *c) 517 524 { 518 525 #ifdef __NEED_VMBITS_PROBE ··· 534 527 switch (isa) { 535 528 case MIPS_CPU_ISA_M64R2: 536 529 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2; 530 + set_elf_base_platform("mips64r2"); 537 531 /* fall through */ 538 532 case MIPS_CPU_ISA_M64R1: 539 533 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1; 534 + set_elf_base_platform("mips64"); 540 535 /* fall through */ 541 536 case MIPS_CPU_ISA_V: 542 537 c->isa_level |= MIPS_CPU_ISA_V; 538 + set_elf_base_platform("mips5"); 543 539 /* fall through */ 544 540 case MIPS_CPU_ISA_IV: 545 541 c->isa_level |= MIPS_CPU_ISA_IV; 542 + set_elf_base_platform("mips4"); 546 543 /* fall through */ 547 544 case MIPS_CPU_ISA_III: 548 545 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III; 546 + set_elf_base_platform("mips3"); 549 547 break; 550 548 551 549 /* R6 incompatible with everything else */ 552 550 case MIPS_CPU_ISA_M64R6: 553 551 c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6; 552 + set_elf_base_platform("mips64r6"); 554 553 /* fall through */ 555 554 case MIPS_CPU_ISA_M32R6: 556 555 c->isa_level |= MIPS_CPU_ISA_M32R6; 556 + set_elf_base_platform("mips32r6"); 557 557 /* Break here so we don't add incompatible ISAs */ 558 558 break; 559 559 case MIPS_CPU_ISA_M32R2: 560 560 c->isa_level |= MIPS_CPU_ISA_M32R2; 561 + set_elf_base_platform("mips32r2"); 561 562 /* fall through */ 562 563 case MIPS_CPU_ISA_M32R1: 563 564 c->isa_level |= MIPS_CPU_ISA_M32R1; 565 + set_elf_base_platform("mips32"); 564 566 /* fall through */ 565 567 case MIPS_CPU_ISA_II: 566 568 c->isa_level |= MIPS_CPU_ISA_II; 569 + set_elf_base_platform("mips2"); 567 570 break; 568 571 } 569 572 } ··· 2130 2113 2131 2114 const char *__cpu_name[NR_CPUS]; 2132 2115 const char *__elf_platform; 2116 + const char *__elf_base_platform; 2133 2117 2134 2118 void cpu_probe(void) 2135 2119 {