Skip to content

Commit e585b76

Browse files
wzssyqatsbogend
authored andcommitted
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 <[email protected]> Reviewed-by: Jiaxun Yang <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent be28076 commit e585b76

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

arch/mips/include/asm/elf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ extern unsigned int elf_hwcap;
445445
#define ELF_PLATFORM __elf_platform
446446
extern const char *__elf_platform;
447447

448+
#define ELF_BASE_PLATFORM __elf_base_platform
449+
extern const char *__elf_base_platform;
450+
448451
/*
449452
* See comments in asm-alpha/elf.h, this is the same thing
450453
* on the MIPS.

arch/mips/kernel/cpu-probe.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,13 @@ static inline void set_elf_platform(int cpu, const char *plat)
513513
__elf_platform = plat;
514514
}
515515

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+
516523
static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
517524
{
518525
#ifdef __NEED_VMBITS_PROBE
@@ -527,36 +534,46 @@ static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
527534
switch (isa) {
528535
case MIPS_CPU_ISA_M64R2:
529536
c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
537+
set_elf_base_platform("mips64r2");
530538
/* fall through */
531539
case MIPS_CPU_ISA_M64R1:
532540
c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
541+
set_elf_base_platform("mips64");
533542
/* fall through */
534543
case MIPS_CPU_ISA_V:
535544
c->isa_level |= MIPS_CPU_ISA_V;
545+
set_elf_base_platform("mips5");
536546
/* fall through */
537547
case MIPS_CPU_ISA_IV:
538548
c->isa_level |= MIPS_CPU_ISA_IV;
549+
set_elf_base_platform("mips4");
539550
/* fall through */
540551
case MIPS_CPU_ISA_III:
541552
c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
553+
set_elf_base_platform("mips3");
542554
break;
543555

544556
/* R6 incompatible with everything else */
545557
case MIPS_CPU_ISA_M64R6:
546558
c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
559+
set_elf_base_platform("mips64r6");
547560
/* fall through */
548561
case MIPS_CPU_ISA_M32R6:
549562
c->isa_level |= MIPS_CPU_ISA_M32R6;
563+
set_elf_base_platform("mips32r6");
550564
/* Break here so we don't add incompatible ISAs */
551565
break;
552566
case MIPS_CPU_ISA_M32R2:
553567
c->isa_level |= MIPS_CPU_ISA_M32R2;
568+
set_elf_base_platform("mips32r2");
554569
/* fall through */
555570
case MIPS_CPU_ISA_M32R1:
556571
c->isa_level |= MIPS_CPU_ISA_M32R1;
572+
set_elf_base_platform("mips32");
557573
/* fall through */
558574
case MIPS_CPU_ISA_II:
559575
c->isa_level |= MIPS_CPU_ISA_II;
576+
set_elf_base_platform("mips2");
560577
break;
561578
}
562579
}
@@ -2113,6 +2130,7 @@ EXPORT_SYMBOL(__ua_limit);
21132130

21142131
const char *__cpu_name[NR_CPUS];
21152132
const char *__elf_platform;
2133+
const char *__elf_base_platform;
21162134

21172135
void cpu_probe(void)
21182136
{

0 commit comments

Comments
 (0)