Merge tag 'pull-ufs-20231205' of https://gitlab.com/jeuk20.kim/qemu into staging
[qemu/ar7.git] / util / cpuinfo-loongarch.c
blob08b6d7460c9f690ecbb3bf6a48641ef80e62a0e0
1 /*
2 * SPDX-License-Identifier: GPL-2.0-or-later
3 * Host specific cpu identification for LoongArch.
4 */
6 #include "qemu/osdep.h"
7 #include "host/cpuinfo.h"
9 #ifdef CONFIG_GETAUXVAL
10 # include <sys/auxv.h>
11 #else
12 # include "elf.h"
13 #endif
14 #include <asm/hwcap.h>
16 unsigned cpuinfo;
18 /* Called both as constructor and (possibly) via other constructors. */
19 unsigned __attribute__((constructor)) cpuinfo_init(void)
21 unsigned info = cpuinfo;
22 unsigned long hwcap;
24 if (info) {
25 return info;
28 hwcap = qemu_getauxval(AT_HWCAP);
30 info = CPUINFO_ALWAYS;
31 info |= (hwcap & HWCAP_LOONGARCH_LSX ? CPUINFO_LSX : 0);
33 cpuinfo = info;
34 return info;