2016-07-12 02:30:49 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "machine.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2016-07-12 16:44:03 -07:00
|
|
|
struct cpuid_out res;
|
2016-07-12 02:30:49 +02:00
|
|
|
|
2018-04-11 13:40:43 +03:00
|
|
|
// Logic below from https://github.com/intel/intel-cmt-cat/blob/master/lib/cap.c
|
2016-07-12 16:44:03 -07:00
|
|
|
// TODO(balajismaniam): Implement L3 CAT detection using brand string and MSR probing if
|
|
|
|
// not detected using cpuid
|
|
|
|
lcpuid(0x7, 0x0, &res);
|
|
|
|
if (!(res.ebx & (1 << 15))) {
|
2016-12-09 14:40:45 -08:00
|
|
|
return EXIT_FAILURE;
|
2016-07-12 16:44:03 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
lcpuid(0x10, 0x0, &res);
|
|
|
|
if (!(res.ebx & (1 << 1))) {
|
2016-12-09 14:40:45 -08:00
|
|
|
return EXIT_FAILURE;
|
2016-07-12 16:44:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-12 11:26:15 -08:00
|
|
|
// If we are here, then L3 cache allocation capability is available.
|
|
|
|
return EXIT_SUCCESS;
|
2016-07-12 02:30:49 +02:00
|
|
|
}
|