8 ms·
Out of curiosity how would you reimplement this file in bash? https://github.com/kaniini/slabbed-or-not/blob/master/xen-detect.c https://github.com/kaniini/slab
by iam 13y ago
Out of curiosity how would you reimplement this file in bash? https://github.com/kaniini/slabbed-or-not/blob/master/xen-detect.c https://github.com/kaniini/slabbed-or-not/blob/master/xen-de...
In particular, the fact that it's using inline asm directly (for cpuid, ud2, some others). Maybe with 'as' but that's not exactly pure bash (and I suspect not embedding it in C would need a non-trivial main function anyway).
Reading an arbitrary memory address (for the cpuid scans) might be a bit tricky too, though it could be doable with /proc/$PID/mem.
- nailer 13y agoCPUID is available in /proc/cpuinfo (or whatever the /sys or modern equivalent is, my Linux is a bit rusty) Not sure re: UD2 though.
- nenolod 13y agoThe point here is that the information in /proc/cpuinfo is virtualized, and therefore may not reflect reality...
- nailer 13y agoWould you have to be a kernel module to access the CPU directly?
- aryastark 13y agoNo. All binary programs access the CPU directly. Only certain instructions require being in a certain "ring" (i.e. access level). The CPUID instruction is non-privileged, meaning you can access it from user space.