• WANG Xuerui's avatar
    MIPS: emulate CPUCFG instruction on older Loongson64 cores · ec7a9318
    WANG Xuerui authored
    CPUCFG is the instruction for querying processor characteristics on
    newer Loongson processors, much like CPUID of x86. Since the instruction
    is supposedly designed to provide a unified way to do feature detection
    (without having to, for example, parse /proc/cpuinfo which is too
    heavyweight), it is important to provide compatibility for older cores
    without native support. Fortunately, most of the fields can be
    synthesized without changes to semantics. Performance is not really big
    a concern, because feature detection logic is not expected to be
    invoked very often in typical userland applications.
    
    The instruction can't be emulated on LOONGSON_2EF cores, according to
    FlyGoat's experiments. Because the LWC2 opcode is assigned to other
    valid instructions on 2E and 2F, no RI exception is raised for us to
    intercept. So compatibility is only extended back furthest to
    Loongson-3A1000. Loongson-2K is covered too, as it is basically a remix
    of various blocks from the 3A/3B models from a kernel perspective.
    
    This is lightly based on Loongson's work on their Linux 3.10 fork, for
    being the authority on the right feature flags to fill in, where things
    aren't otherwise discoverable.
    Signed-off-by: default avatarWANG Xuerui <git@xen0n.name>
    Reviewed-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
    Cc: Huacai Chen <chenhc@lemote.com>
    Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
    Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
    Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
    ec7a9318
cpu-info.h 6.16 KB