mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 09:39:13 +00:00
This patch add ability to test /proc/cpuinfo data we're interested in at the moment. The code provides the following functionality - cpu_init, to parse cpuinfo and check if the host cpu we're running on is suitable enough for FPU checkpoint/restore. If FPU present then there must be at least fxsave capability present - cpu_set_feature/cpu_has_feature helpers which provides to test certain bits and set them where needed (we need to set bits when parse cpuinfo) Note, we reserve space for all cpuinfo bits known by the kernel at moment, while use only three FPU related bits for a while. This is done because we might need to use or find out other features in future. After all it's just 40 bytes of memory needed to keep all possible bits. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
23 lines
593 B
C
23 lines
593 B
C
#ifndef CPU_H__
|
|
#define CPU_H__
|
|
|
|
#include "types.h"
|
|
|
|
/*
|
|
* Adopted from linux kernel.
|
|
*/
|
|
|
|
#define NCAPINTS (10) /* N 32-bit words worth of info */
|
|
#define NCAPINTS_BITS (NCAPINTS * 32)
|
|
|
|
#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
|
|
#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE/FXRSTOR, CR4.OSFXSR */
|
|
#define X86_FEATURE_XSAVE (4*32+26) /* XSAVE/XRSTOR/XSETBV/XGETBV */
|
|
|
|
extern const char * const x86_cap_flags[NCAPINTS_BITS];
|
|
|
|
extern void cpu_set_feature(unsigned int feature);
|
|
extern bool cpu_has_feature(unsigned int feature);
|
|
extern int cpu_init(void);
|
|
|
|
#endif /* CPU_H__ */
|